Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

how to stop a databound combo box from selecting first item when refreshing the bound list source

$
0
0

I have a form with several comboboxes that have databound lists. Everything works fine when using the form normally but I have a "Quick Add" button that opens the related maintenance form for that field that the user then can edit or add to the list. On the Save command of the maintenance form it check for the form that opened it and then refreshed the appropriate datatable that supplies the list for the combobox(Which works). The issue is that it will always reset theselected item of the combo box to the first item in the list as opposed to what it was originally. it is still functional as more then likely the person will change it to the item they just entered/edited but it leaves room for issues. ie if they change their mind but save the data it would be the the first item, not what was originally in the combobox and they may not notice.

For Example

frmParty
comboBox1 = PartyCountryCode
Databound list to tCountry
Display member CountryName
Value Member = CountryCode VarChar(2)

The Parties Entry is opened and the Country is Bahamas.
They Quick add Germany and save the new country. which would be 3 columns ID,Label,ifActive
When frmParty comes active combobox1 is now set to Afghanistan (First Item)

I want to have it go to the Bahamas after the bindingsource for the list of combobox1 is filled

Done in VB.Net VS Express 2013



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>