Click here to Skip to main content
16,004,991 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Word.Application how to load to object without open Pin
vancouver77712-Jul-04 0:59
vancouver77712-Jul-04 0:59 
GeneralRe: Word.Application how to load to object without open Pin
vancouver77712-Jul-04 7:59
vancouver77712-Jul-04 7:59 
Generaldisplay word file Pin
nazerudeen11-Jul-04 2:21
nazerudeen11-Jul-04 2:21 
GeneralRe: display word file Pin
Dave Kreskowiak11-Jul-04 17:06
mveDave Kreskowiak11-Jul-04 17:06 
GeneralProblem with ADO, ADO.NET and VB.NET Pin
Mekong River10-Jul-04 6:30
Mekong River10-Jul-04 6:30 
GeneralTransfer pop3 to Exchange Pin
sybux200010-Jul-04 5:11
sybux200010-Jul-04 5:11 
GeneralData Filling and Handelling in VB.NET using DataGrid Pin
Thangaraj P.V.10-Jul-04 3:48
Thangaraj P.V.10-Jul-04 3:48 
GeneralRe: Data Filling and Handelling in VB.NET using DataGrid Pin
Syed Abdul Khader11-Jul-04 23:06
Syed Abdul Khader11-Jul-04 23:06 
Hi,

There is a great sample for doing this in MSDN. I am just giving it.

Imports System<br />
Imports System.Data<br />
Imports System.Windows.Forms<br />
Imports System.Drawing<br />
Imports System.ComponentModel<br />
<br />
' This example shows how to create your own column style that<br />
' hosts a control, in this case, a DateTimePicker.<br />
Public Class DataGridTimePickerColumn<br />
    Inherits DataGridColumnStyle<br />
    Private timePicker As New DateTimePicker()<br />
    ' The isEditing field tracks whether or not the user is<br />
    ' editing data with the hosted control.<br />
    Private isEditing As Boolean<br />
<br />
    Public Sub New()<br />
        timePicker.Visible = False<br />
    End Sub<br />
<br />
    Protected Overrides Sub Abort(ByVal rowNum As Integer)<br />
        isEditing = False<br />
        RemoveHandler timePicker.ValueChanged, _<br />
        AddressOf TimePickerValueChanged<br />
        Invalidate()<br />
    End Sub<br />
<br />
    Protected Overrides Function Commit _<br />
    (ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _<br />
    As Boolean<br />
        timePicker.Bounds = Rectangle.Empty<br />
<br />
        AddHandler timePicker.ValueChanged, _<br />
        AddressOf TimePickerValueChanged<br />
<br />
        If Not isEditing Then<br />
            Return True<br />
        End If<br />
        isEditing = False<br />
<br />
        Try<br />
            Dim value As DateTime = timePicker.Value<br />
            SetColumnValueAtRow(dataSource, rowNum, value)<br />
        Catch<br />
        End Try<br />
<br />
        Invalidate()<br />
        Return True<br />
    End Function<br />
<br />
    Protected Overloads Overrides Sub Edit( _<br />
    ByVal [source] As CurrencyManager, _<br />
    ByVal rowNum As Integer, _<br />
    ByVal bounds As Rectangle, _<br />
    ByVal [readOnly] As Boolean, _<br />
    ByVal instantText As String, _<br />
    ByVal cellIsVisible As Boolean)<br />
        Dim value As DateTime = _<br />
        CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
        If cellIsVisible Then<br />
            timePicker.Bounds = New Rectangle _<br />
            (bounds.X + 2, bounds.Y + 2, bounds.Width - 4, _<br />
            bounds.Height - 4)<br />
<br />
            timePicker.Value = value<br />
            timePicker.Visible = True<br />
            AddHandler timePicker.ValueChanged, _<br />
            AddressOf TimePickerValueChanged<br />
        Else<br />
            timePicker.Value = value<br />
            timePicker.Visible = False<br />
        End If<br />
<br />
        If timePicker.Visible Then<br />
            DataGridTableStyle.DataGrid.Invalidate(bounds)<br />
        End If<br />
    End Sub<br />
<br />
    Protected Overrides Function GetPreferredSize( _<br />
    ByVal g As Graphics, _<br />
    ByVal value As Object) As Size<br />
        Return New Size(100, timePicker.PreferredHeight + 4)<br />
    End Function<br />
<br />
    Protected Overrides Function GetMinimumHeight() As Integer<br />
        Return timePicker.PreferredHeight + 4<br />
    End Function<br />
<br />
<br />
    Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer<br />
        Return timePicker.PreferredHeight + 4<br />
    End Function<br />
<br />
<br />
    Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)<br />
        Paint(g, bounds, [source], rowNum, False)<br />
    End Sub<br />
<br />
    Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)<br />
        Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)<br />
    End Sub<br />
<br />
    Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)<br />
        Dim [date] As DateTime = CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
        Dim rect As Rectangle = bounds<br />
        g.FillRectangle(backBrush, rect)<br />
        rect.Offset(0, 2)<br />
        rect.Height -= 2<br />
        g.DrawString([date].ToString("d"), Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))<br />
    End Sub<br />
<br />
    Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)<br />
        MyBase.SetDataGridInColumn(value)<br />
        If Not (timePicker.Parent Is Nothing) Then<br />
            timePicker.Parent.Controls.Remove(timePicker)<br />
        End If<br />
        If Not (value Is Nothing) Then<br />
            value.Controls.Add(timePicker)<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub TimePickerValueChanged(ByVal sender As Object, ByVal e As EventArgs)<br />
        Me.isEditing = True<br />
        MyBase.ColumnStartedEditing(timePicker)<br />
    End Sub<br />
End Class<br />
<br />
Namespace DataGridColumnStyleExample<br />
    Public Class MyForm<br />
        Inherits Form<br />
<br />
        Private namesDataTable As dataTable<br />
        Private myGrid As DataGrid = New DataGrid()<br />
        Public Sub New()<br />
<br />
            InitForm()<br />
<br />
            namesDataTable = New DataTable("NamesTable")<br />
            namesDataTable.Columns.Add(New DataColumn("Name"))<br />
            Dim dateColumn As DataColumn = _<br />
            New DataColumn("Date", GetType(DateTime))<br />
            namesDataTable.Columns.Add(dateColumn)<br />
            Dim namesDataSet As DataSet = New DataSet()<br />
            namesDataSet.Tables.Add(namesDataTable)<br />
            myGrid.DataSource = namesDataSet<br />
            myGrid.DataMember = "NamesTable"<br />
            AddGridStyle()<br />
            AddData()<br />
        End Sub<br />
<br />
        Private Sub AddGridStyle()<br />
            Dim myGridStyle As DataGridTableStyle = _<br />
                        New DataGridTableStyle()<br />
            myGridStyle.MappingName = "NamesTable"<br />
<br />
            Dim nameColumnStyle As DataGridTextBoxColumn = _<br />
                New DataGridTextBoxColumn()<br />
            nameColumnStyle.MappingName = "Name"<br />
            nameColumnStyle.HeaderText = "Name"<br />
            myGridStyle.GridColumnStyles.Add(nameColumnStyle)<br />
<br />
            Dim timePickerColumnStyle As DataGridTimePickerColumn = _<br />
                New DataGridTimePickerColumn()<br />
            timePickerColumnStyle.MappingName = "Date"<br />
            timePickerColumnStyle.HeaderText = "Date"<br />
            timePickerColumnStyle.Width = 100<br />
            myGridStyle.GridColumnStyles.Add(timePickerColumnStyle)<br />
<br />
            myGrid.TableStyles.Add(myGridStyle)<br />
        End Sub<br />
<br />
        Private Sub AddData()<br />
            Dim dRow As DataRow = namesDataTable.NewRow()<br />
            dRow("Name") = "Name 1"<br />
            dRow("Date") = New DateTime(2001, 12, 1)<br />
            namesDataTable.Rows.Add(dRow)<br />
<br />
            dRow = namesDataTable.NewRow()<br />
            dRow("Name") = "Name 2"<br />
            dRow("Date") = New DateTime(2001, 12, 4)<br />
            namesDataTable.Rows.Add(dRow)<br />
<br />
            dRow = namesDataTable.NewRow()<br />
            dRow("Name") = "Name 3"<br />
            dRow("Date") = New DateTime(2001, 12, 29)<br />
            namesDataTable.Rows.Add(dRow)<br />
<br />
            dRow = namesDataTable.NewRow()<br />
            dRow("Name") = "Name 4"<br />
            dRow("Date") = New DateTime(2001, 12, 13)<br />
            namesDataTable.Rows.Add(dRow)<br />
<br />
            dRow = namesDataTable.NewRow()<br />
            dRow("Name") = "Name 5"<br />
            dRow("Date") = New DateTime(2001, 12, 21)<br />
            namesDataTable.Rows.Add(dRow)<br />
<br />
            namesDataTable.AcceptChanges()<br />
        End Sub<br />
<br />
        Private Sub InitForm()<br />
<br />
            Me.Size = New Size(500, 500)<br />
            myGrid.Size = New Size(350, 250)<br />
            myGrid.TabStop = True<br />
            myGrid.TabIndex = 1<br />
            Me.StartPosition = FormStartPosition.CenterScreen<br />
            Me.Controls.Add(myGrid)<br />
        End Sub<br />
<br />
        <STAThread()> _<br />
        Public Shared Sub Main()<br />
            Application.Run(New MyForm())<br />
        End Sub<br />
    End Class

GeneralRe: Data Filling and Handelling in VB.NET using DataGrid Pin
Ravi S.V.12-Jul-04 0:01
Ravi S.V.12-Jul-04 0:01 
QuestionLock Monitor, Keyboad and Mouse - How??? Pin
tommy_tanaka9-Jul-04 23:00
tommy_tanaka9-Jul-04 23:00 
AnswerRe: Lock Monitor, Keyboad and Mouse - How??? Pin
Dave Kreskowiak10-Jul-04 14:31
mveDave Kreskowiak10-Jul-04 14:31 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
tommy_tanaka11-Jul-04 7:39
tommy_tanaka11-Jul-04 7:39 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
Dave Kreskowiak11-Jul-04 8:55
mveDave Kreskowiak11-Jul-04 8:55 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
tommy_tanaka12-Jul-04 2:15
tommy_tanaka12-Jul-04 2:15 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
Dave Kreskowiak12-Jul-04 5:30
mveDave Kreskowiak12-Jul-04 5:30 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
tommy_tanaka12-Jul-04 5:50
tommy_tanaka12-Jul-04 5:50 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
Dave Kreskowiak12-Jul-04 13:28
mveDave Kreskowiak12-Jul-04 13:28 
GeneralRe: Lock Monitor, Keyboad and Mouse - How??? Pin
James Gohl14-Jul-04 8:58
James Gohl14-Jul-04 8:58 
GeneralPrint to a File Pin
gthompson20059-Jul-04 19:11
gthompson20059-Jul-04 19:11 
GeneralRe: Print to a File Pin
Dave Kreskowiak10-Jul-04 14:06
mveDave Kreskowiak10-Jul-04 14:06 
GeneralRe: Print to a File Pin
gthompson200510-Jul-04 14:31
gthompson200510-Jul-04 14:31 
GeneralRe: Print to a File Pin
Dave Kreskowiak10-Jul-04 14:42
mveDave Kreskowiak10-Jul-04 14:42 
GeneralRe: Print to a File Pin
gthompson200510-Jul-04 15:01
gthompson200510-Jul-04 15:01 
Generalmodeless dialog Pin
nnjj9-Jul-04 6:14
nnjj9-Jul-04 6:14 
GeneralDebug levels Pin
Boniolopez9-Jul-04 3:30
Boniolopez9-Jul-04 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.