Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Events on a bound control
 

Events on a bound control

I have a lookup combo box that is bound to an employee class through the valuemember property.  I can change the value selected in the GUI and the change hits the employee class public property for this field (set) automatically.  However, no events are fired off until the cursor is moved from the field.  I want to do some validation on this change before I allow the user to change the value.  What is the best way to accomplish this?
MigrationUser 1  Friday, January 31, 2003 7:19 AM
Try the SelectedIndexChanged event.  That will let you know when the user chooses a new value.

 - mike
MigrationUser 1  Friday, January 31, 2003 5:52 PM
I find that in the things I do, using the SelectionChangeCommitted works better (might be the case for you, but I thought I'd throw it out anyway) than using SelectedIndexChanged.

The difference between the two events is that SelectedIndexChanged fires anytime the SelectedItem is changed, whether it is programmatic (done by you) or by the user, which works most of the time, but can sometimes get funky when linking two (or more) combo boxes together.  The SelectionChangeCommitted event only fires off when the user changes which item is selected.

michael harsh is definitely right though.  Use an event of the Combo Box to detect when they selected a different item
MigrationUser 1  Sunday, February 02, 2003 3:47 PM

You can use google to search for other answers

Custom Search

More Threads

• Combo box and Datasource
• How to begin editing of a DataGridView cell on click?
• Changing DataBound values w/o Changing Focus
• Help needed(visual basic 2008): extract cells from .mdb database
• Convert datagridview data to temp table
• DataGridView comboBox filter with two DataTables
• export the data from text file to the table in the Database
• get recordsets from underlying BINDINGSOURCE
• how to correct this?
• Initializing a Windows Forms datagrid