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
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
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.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.Code:dayComboBox.DataSource = Enumerable.Range(1, 31).ToArray()
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Pausing Code) | C#
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
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.
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.
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Pausing Code) | C#
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces