How to link a data row to datetimepicker

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2007
Posts: 3
Reputation: goldfish999 is an unknown quantity at this point 
Solved Threads: 0
goldfish999 goldfish999 is offline Offline
Newbie Poster

How to link a data row to datetimepicker

 
0
  #1
Sep 4th, 2007
I have a Table with a 'Dates' Field as the primary key and 20 other Fields of Integer Type. This is the Master Table with 9 other Detail Tables all with a 'Dates' key field. I have a form to view all this and it works fine.
My problem is to select the row of the Master Table with a date selected by a DateTimePicker Component instead of having to click through lots of rows until I get to the required date.
I have tried all sorts of ways but cannot get close - I have no sample code because nothing I have tried works for me !!
I feel a right idiot because it must be very simple to do it.
Please help !!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: How to link a data row to datetimepicker

 
0
  #2
Sep 4th, 2007
Did you try databinding?
  1. DateTimePicker1.DataBindings.Add( "Value", MasterTable, "Dates" )
I don't think that'll work very well though. If you pick a date that isn't in the table, you'll probably get an exception. How about using a combo box instead of a date time picker? That makes more sense because you're picking from a subset of dates that exist in the table, but a date time picker lets you pick from all possible dates.
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 3
Reputation: goldfish999 is an unknown quantity at this point 
Solved Threads: 0
goldfish999 goldfish999 is offline Offline
Newbie Poster

Re: How to link a data row to datetimepicker

 
0
  #3
Sep 4th, 2007
Hi
Thanks very much. Got it to work after a while. I am new to VB. Last time i used it was way back in version 1.
It is not quite what I was wanting but is good enough. I see the datetimepicker does not have 'DataSource' and 'DisplayMember' properties. Would it very difficult to add these properties? I have done a bit of modifying components in Delphi.
Thanks again - I will be able to sleep tonight. I live in South Africa so it is getting to bedtime.
Alan
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: How to link a data row to datetimepicker

 
0
  #4
Sep 4th, 2007
I see the datetimepicker does not have 'DataSource' and 'DisplayMember' properties.
I don't think they make sense for the date time picker. There's probably a few ways you can define them for the control, but I can't think of any that make a date time picker the better choice than a combo box or some other aggregate control except for what the date time picker does now without those two properties.

Would it very difficult to add these properties?
I don't think so, but you'd have to do a lot of micromanagement to make sure that only the data source dates can be selected by the calendar dropdown or spinners.
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 3
Reputation: goldfish999 is an unknown quantity at this point 
Solved Threads: 0
goldfish999 goldfish999 is offline Offline
Newbie Poster

Re: How to link a data row to datetimepicker

 
0
  #5
Sep 5th, 2007
Thanks for the help. My problem with the combobox is that i have info going back 5 years and the Datetimepicker is easier to use to find the old data if needed.
I think I will try and learn more about VB before experimenting further.
Once again many thanks
Alan
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: How to link a data row to datetimepicker

 
0
  #6
Sep 5th, 2007
My problem with the combobox is that i have info going back 5 years and the Datetimepicker is easier to use to find the old data if needed.
That's where you can use a date time picker and use the year in its value to filter the data source so that you don't get 5 years of dates in the combo box.
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC