DateTimePicker on datagridView - 03-01-2006 , 09:18 AM
In table dtTasks there are 3 fields, ID, Name and birthDate.
I fill dtTasks with adapter and bind it like below.
dgview.DataSource = dtTasks;
Code above automatically creates columns and insert rows to
At this point i want to select Birth date from dateTimePicker.
I need a code that will make me use DateTimePicker for Birthdate
But i don't want to add columns and rows manually.
Thanks and best regards.
RE: DateTimePicker on datagridView - 03-06-2006 , 03:21 PM
To host a DateTimePicker in a DataGridView column you must define a new class
that inherits from DataGridViewColumn. You can find the whole class in the
documentation “How to: Host Controls in Windows Forms DataGridView Cells”,
it’s called CalendarColumn (in my machine, the cocumentation address is:
In the example you will find a form called Form1, you may take it off.
Copy the code, add a new item to the project of type class.vb, and paste the
Now, when creating the dataGridView, if you dropped it from the toolBox, you
must first remove the column from the DataGridView, since you will create the
Then, in the Form’s Load Event Handler, you must write (suppose your
dataGridView control is called myDataGridView):
Dim CalendarCol As New CalendarColumn()
CalendarCol.Name = "<the name of the column>"
CalendarCol.DataPropertyName = "<the name of the field in the DataBase>"
Hope this helps!
|Thread Tools||Search this Thread|