|
-
Aug 20th, 2012, 11:26 AM
#1
Thread Starter
Addicted Member
Birthday comboboxes database
Hello, I have bound 3 comboboxes to my database(for the date of birth), but then the items were 'deleted' and I couldn't edit the collection anymore.
Is it possible to set the items in the comboboxes 1-31, 1-12, 1900-2012?
thanks in advance
-
Aug 20th, 2012, 11:43 AM
#2
Re: Birthday comboboxes database
Yes it is, but why bother? Why not just use a DateTimePicker and let the user choose a single date? No validation or conversion required. Using drop-downs is a bit of a web thing but, with jQuery, more and more web sites are using a single field with a calendar on it because it's just plain better than three drop-downs.
If you really must use ComboBoxes then, e.g.
Code:
dayComboBox.DataSource = Enumerable.Range(1, 31).ToArray()
Just remember that it will then be possible for the user to select a combination that is not a valid date, which is one of the reasons that a DTP is better.
-
Aug 20th, 2012, 11:58 AM
#3
Thread Starter
Addicted Member
Re: Birthday comboboxes database
Then would you mind explaining me how to bind a dtp to a database? Also, I want a man/woman combobox but dont know how to get the items in the combobox.
-
Aug 20th, 2012, 06:08 PM
#4
Re: Birthday comboboxes database
You bind a DateTimePicker the same way you bind any other control, i.e. via its DataBindings property. Just note that a DateTimePicker doesn't support binding to nullable data, so binding would not be an option if date of birth is not mandatory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|