|
-
May 9th, 2013, 09:13 AM
#1
Thread Starter
Hyperactive Member
[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.
-
May 9th, 2013, 09:24 AM
#2
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!
-
May 9th, 2013, 10:04 AM
#3
Thread Starter
Hyperactive Member
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.
-
May 9th, 2013, 10:24 AM
#4
Re: How to display bound column in ComboBox when form loads in vb 2010 Express
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!
-
May 9th, 2013, 10:41 AM
#5
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.
-
May 9th, 2013, 02:35 PM
#6
Thread Starter
Hyperactive Member
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!!
-
May 10th, 2013, 12:37 AM
#7
Re: How to display bound column in ComboBox when form loads in vb 2010 Express
 Originally Posted by DexterRose
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".
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
|