Results 1 to 4 of 4

Thread: Birthday comboboxes database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    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
  •  



Click Here to Expand Forum to Full Width