HighTechTalks DotNet Forums  

DateTimePicker on datagridView

Dotnet Data Tools microsoft.public.dotnet.datatools


Discuss DateTimePicker on datagridView in the Dotnet Data Tools forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Cenk
 
Posts: n/a

Default DateTimePicker on datagridView - 03-01-2006 , 09:18 AM






Hi all

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
datagridview.
At this point i want to select Birth date from dateTimePicker.

I need a code that will make me use DateTimePicker for Birthdate
column.

But i don't want to add columns and rows manually.

Thanks and best regards.


Reply With Quote
  #2  
Old   
Other_Developer_More
 
Posts: n/a

Default 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:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/html/e79a9d4e-64ec-41f5-93ec-f5492633cbb2.htm).
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
code there.

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
column programmatically.

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>"
myDataGridView.Columns.Add(CalendarCol)

Done.

Hope this helps!

--

Other_Developer_More


"Cenk" wrote:

Quote:
Hi all

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
datagridview.
At this point i want to select Birth date from dateTimePicker.

I need a code that will make me use DateTimePicker for Birthdate
column.

But i don't want to add columns and rows manually.

Thanks and best regards.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.