Results 1 to 7 of 7

Thread: [SOLVED] How to display bound column in ComboBox when form loads in vb 2010 Express

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    [SOLVED] How to display bound column in ComboBox when form loads in vb 2010 Express

    I am new to VB 2010.
    I have set the properties of the combobox as below:

    I have a ComboBox whose Display Source is set to "Managers Binding Source" and Display Member is set to "Manager Name".
    Under DataBindings I have the Text property set to "Salesperson Binding Source - SalespersonManager".

    When I select a manager name in the comboBox the Salesperson database is updated with the newly selected Manager Name just fine.

    My problem is, when the form loads the next time, the ComboBox shows the first Manager in the Display Member list INSTEAD OF THE MANAGER THAT THIS COMBOBOX IS BOUND TO.

    How do I get the bound column to display in the combobox instead of the first member of the Display Mamber list??
    Last edited by DexterRose; May 9th, 2013 at 02:36 PM.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    The ComboBox is BOUND to a list of values that is initialised when the form loads. Selections don't carry over as if by magic. If you want a particular item to be the first that is seen then you must save that setting in some way and apply it again when the form loads or you must hide the form rather than closing it.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    I had tried adding a separate bound Textbox and setting the ComboBox.text = Textbox.text and this worked fine but I thought there had to be a better way. Wasn't a problem in VB5.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    Wasn't a problem in VB5.
    If you'll forgive the pun, I suspect that's the Rose coloured spectacles talking! It's not a problem introduced by .Net. It's not a problem at all, in fact. As I said, it's simply that a form will inevitably reinitialise every time it goes through a full load.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,510

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    Just dealt with this problem yesterday. I found you must "Fill" the datatable for the combobox datasource (listitems) before you "Fill" the datatable that the combobox is bound to, in your case the Salesperson.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    Well, are you not the HERO!!

    I switched the order of the "TableAdapter.Fill" code in the Load Event, and wala, the ComboBox performs as you would think it should!!!!!!!

    It would really be nice if MS would put info like this in their documentation of their controls.

    Thanks again!!

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to display bound column in ComboBox when form loads in vb 2010 Express

    Quote Originally Posted by DexterRose View Post
    I switched the order of the "TableAdapter.Fill" code in the Load Event, and wala, the ComboBox performs as you would think it should!!!!!!!
    Just so you know, there's no such word as "wala". It's "voila", which is French for (if memory serves) "there it is".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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