Data Filling and Handelling in VB.NET using DataGrid
-
Hi, Can anyone tell me is this possible..... I want to fill the DataGrid. I have 5 columns selected in the Query using Joins from 2 Tables. I want to Fill the Datas in the Grid along with it, add 2 more columns to be added in the Grid, but the 2 added columns should be used as Date Picker. This is for VB.NET application. and it is a Very urgent task to Complete. pls help me out in doing this Task. (Note: I'm NEW to .NET) Thanx and Regards, Tthangaraj P.V. tthangarajpv@yahoo.com
-
Hi, Can anyone tell me is this possible..... I want to fill the DataGrid. I have 5 columns selected in the Query using Joins from 2 Tables. I want to Fill the Datas in the Grid along with it, add 2 more columns to be added in the Grid, but the 2 added columns should be used as Date Picker. This is for VB.NET application. and it is a Very urgent task to Complete. pls help me out in doing this Task. (Note: I'm NEW to .NET) Thanx and Regards, Tthangaraj P.V. tthangarajpv@yahoo.com
Hi, There is a great sample for doing this in MSDN. I am just giving it.
Imports System Imports System.Data Imports System.Windows.Forms Imports System.Drawing Imports System.ComponentModel ' This example shows how to create your own column style that ' hosts a control, in this case, a DateTimePicker. Public Class DataGridTimePickerColumn Inherits DataGridColumnStyle Private timePicker As New DateTimePicker() ' The isEditing field tracks whether or not the user is ' editing data with the hosted control. Private isEditing As Boolean Public Sub New() timePicker.Visible = False End Sub Protected Overrides Sub Abort(ByVal rowNum As Integer) isEditing = False RemoveHandler timePicker.ValueChanged, _ AddressOf TimePickerValueChanged Invalidate() End Sub Protected Overrides Function Commit _ (ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _ As Boolean timePicker.Bounds = Rectangle.Empty AddHandler timePicker.ValueChanged, _ AddressOf TimePickerValueChanged If Not isEditing Then Return True End If isEditing = False Try Dim value As DateTime = timePicker.Value SetColumnValueAtRow(dataSource, rowNum, value) Catch End Try Invalidate() Return True End Function Protected Overloads Overrides Sub Edit( _ ByVal [source] As CurrencyManager, _ ByVal rowNum As Integer, _ ByVal bounds As Rectangle, _ ByVal [readOnly] As Boolean, _ ByVal instantText As String, _ ByVal cellIsVisible As Boolean) Dim value As DateTime = _ CType(GetColumnValueAtRow([source], rowNum), DateTime) If cellIsVisible Then timePicker.Bounds = New Rectangle _ (bounds.X + 2, bounds.Y + 2, bounds.Width - 4, _ bounds.Height - 4) timePicker.Value = value timePicker.Visible = True AddHandler timePicker.ValueChanged, _ AddressOf TimePickerValueChanged Else timePicker.Value = value timePicker.Visible = False End If If timePicker.Visible Then DataGridTableStyle.DataGrid.Invalidate(bounds) End If End Sub Protected Overrides Function GetPreferredSize( _ ByVal g As Graphics, _ ByVal value As Object) As Size Return New Size(
-
Hi, Can anyone tell me is this possible..... I want to fill the DataGrid. I have 5 columns selected in the Query using Joins from 2 Tables. I want to Fill the Datas in the Grid along with it, add 2 more columns to be added in the Grid, but the 2 added columns should be used as Date Picker. This is for VB.NET application. and it is a Very urgent task to Complete. pls help me out in doing this Task. (Note: I'm NEW to .NET) Thanx and Regards, Tthangaraj P.V. tthangarajpv@yahoo.com