WinForms - Prevent ComboBox Mode Changing - DropDownList
In Winforms, what is the correct way to keep the user from changing the DropDown value? I want to prompt the user to say there are unsaved changes. If the user chooses not to discard these changes, I want to discard the combo box change. Any ideas on how to do this?
I, although I've seen the e.Cancel option before. But maybe not in System.Windows.Forms.ComboBox.
UPDATE : To further explain, the ComboBox is not part of the data entry form. It is used as a navigator / filter. The user made changes to the grid. I want them to be unable to navigate off the grid without getting prompted.
source to share
I'm not sure if I fully understand your question, but it seems that your question is not actually directly related to the ComboBox, but rather how to reset the form to its original values ββwhen the user prefers not to save the changes they just made ...
Presumably you have a method on your form that loads controls from values ββin some data structure (maybe an ORM or DataRow object). The easiest way to reset your form to its original (pre-edited) values ββis to simply call this method again with the original (unchanged) data structure.
Update : well, an easy way to do this is to set the ComboBox Enabled property to a value false
as soon as they change anything on the form, and then set it back to true
as soon as they save or discard their changes.
source to share