Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I have a listbox that is bound to a bindingsource bsDATA; my text boxes on the form are also bound to this same datasource. the Listbox DisplayValue = IDfield, DisplayMember = Namefield. My textbox is databound to the Namefield (so it can be edited). The advantage is changes are seen in both the listbox and the textbox, The problem is the SelectedIndexChanged event fires when simply the value of the Namefield is changed by the textbox, which causes the listbox to rebind . I have code that must only run if they change the index from the listbox.

How can I decouple these two components, so the user can change the text in the textbox and not fire the selected indexchanged event, and if the user should change the selected index - I can check my IsDirtyFlag and post a message saying you can't do that unless you answer my questions as to what you want to do , ie discard or save changes. I thought while writing this to use the Who has focus check [for example if listbox has focus change the index, if not skip it , not sure if that is a good way or not. What is the best way to handle this situation?
Posted
Updated 2-Mar-15 8:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900