Answered by:
datetimepicker bind to datagridview question

Question
-
is it possible to bind a datetimpicker to a datetime column in datagridv
if so how can i do that
Wednesday, September 15, 2010 6:03 PM
Answers
-
hello jwavila thanx for reply
i've tried
this line
DateTimePicker1.DataBindings.Add(New Binding("Value", dtTest, "BirthDate"))
but it doesn't work
- Marked as answer by cliftonmenig Sunday, September 19, 2010 4:23 AM
Thursday, September 16, 2010 5:27 AM -
If you put your own propertynames in the code from jwavilla it will go probably better, that is what Jwavilla wrote.
DateTimePicker1.DataBindings.Add(New Binding("Value", YourDataTable, "YourDataTableColumname"))
Success
Cor- Marked as answer by cliftonmenig Sunday, September 19, 2010 4:23 AM
Thursday, September 16, 2010 9:23 AM
All replies
-
yes you can bind a DTP to a Column in your datatable - you should always work with the underlying datatable when possible. The DGV should just be for displaying the data
it's something like this:
where Value is the DTP Property to bind to, dtTest is the datatable and BirthDate is the datatable column to bind toDateTimePicker1.DataBindings.Add(New Binding("Value", dtTest, "BirthDate"))
- Proposed as answer by Cor Ligthert Thursday, September 16, 2010 9:23 AM
Wednesday, September 15, 2010 6:48 PM -
hello jwavila thanx for reply
i've tried
this line
DateTimePicker1.DataBindings.Add(New Binding("Value", dtTest, "BirthDate"))
but it doesn't work
- Marked as answer by cliftonmenig Sunday, September 19, 2010 4:23 AM
Thursday, September 16, 2010 5:27 AM -
uhhh...
you have to put in your table name where it says dtTest and the column name of your date column where it says BirthDate.
Thursday, September 16, 2010 6:01 AM -
yess that part i understand
i allready have
i'm going to explan what i want
i have rows with index 0 to 10 with same value in column "datevalue"
and rows index 11 to 20 with same value and also rows index 21 to 30 with same value
and i want to select one of the values in datetimepicker
and only those rows with the selected value should be visible in datagrid
so thats why i want to bind the datetimepicker to the datagrid
Thursday, September 16, 2010 8:05 AM -
If you put your own propertynames in the code from jwavilla it will go probably better, that is what Jwavilla wrote.
DateTimePicker1.DataBindings.Add(New Binding("Value", YourDataTable, "YourDataTableColumname"))
Success
Cor- Marked as answer by cliftonmenig Sunday, September 19, 2010 4:23 AM
Thursday, September 16, 2010 9:23 AM