944,122 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 4699
  • VB.NET RSS
Sep 4th, 2007
0

How to link a data row to datetimepicker

Expand Post »
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 !!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
goldfish999 is offline Offline
3 posts
since Sep 2007
Sep 4th, 2007
0

Re: How to link a data row to datetimepicker

Did you try databinding?
vbnet Syntax (Toggle Plain Text)
  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.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 4th, 2007
0

Re: How to link a data row to datetimepicker

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
goldfish999 is offline Offline
3 posts
since Sep 2007
Sep 4th, 2007
0

Re: How to link a data row to datetimepicker

Quote ...
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.

Quote ...
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.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 5th, 2007
0

Re: How to link a data row to datetimepicker

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
goldfish999 is offline Offline
3 posts
since Sep 2007
Sep 5th, 2007
0

Re: How to link a data row to datetimepicker

Quote ...
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.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Threading, Delegates and the Invoke method.
Next Thread in VB.NET Forum Timeline: DataSets in Excel to be used in VB





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC