I have a ComboBox bound to a table field and I want to validate the selection, since only certain selections are valid depending on context. When in the On Validating Event how can I get the Value before or what it is in the table.field before selection changed?
Share
The WinForms ComboBox control doesn’t provide the functionality of being able to intercept a value change and cancel it. You can use the
Validatingevent (or, as you describe, subclass the ComboBox and overrideOnValidating), but these only allow you to keep the focus on the control. You can’t actually “cancel” a value change through the validating events.There are several third-party (DevExpress, for example) packages that provide ComboBoxes that allow you to inspect both the initial and the new values when the value changes and cancel the change if desired, but the ComboBox provided in System.Windows.Forms does not.