ComboBox Binding Glitch

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
When browsing through the data on the form, if the combo box has data to display it shows correctly.
When navigating to the next record, if there is no data to bind (I.E null) it will show the first value of the combobox items. This is then misleading to the user.
If the next record is null for the combobox field then the combobox is blank again. Browsing back a record will then show a blank combobox.


- The combobox binds to a lookup dataset, I have declared this as a global variable and it is filled when the app main form opens.
Then on the search form the combo box values (.dataSource, .displayMember etc etc) is set when the form loads.


I've played around with selectedValue but that doesn't fix it. what I need to try and get the following into code for my navigational buttons, or someone suggest a correct solution :D

if dataset1.tables("table1").column("SecondChoice").field is null then
me.combobox1.text = ""

Hopefully that makes sense and someone can give some advice

Cheers,
Luke
 
I found a quick solution, although it adds more code to each form...

I added a textbox next to each combobox. I bound these textboxes to the field in the main table, the same as which the comboboxes are (But the dataSource, displayMember, valueMember are all set to another dataSet)

On the Navigational Buttons Click commands, I've added the following code

VB.NET:
If me.textbox1.text="" then
   me.combobox1.selectedIndex=-1
end If
 
If me.textbox2.text="" then
   me.combobox2.selectedIndex=-1
end If

Not pretty but it does the job.... if anyone knows a better alternative please could they share.

Luke
 
Back
Top