Windows Experts:
1. I have a desktop application with a UserControl that contains
controls: TextBoxes, RadioButtons, CheckBoxes and NumericUpDowns.
2. I want to warn the user that, if there is unsaved data within my
UserControl when he tries to 'X' out of the entire application, to
display a MessageBox.
3. Unfortunately, System.Windows.Forms.UserControl does not have a
Closing event, so I use the Closing event of the Form that is calling
my UserControl.
4. During the MainForm.OnClosing() processing, if I set e.Cancel =
true; (to return back to my UserControl), some controls work and some
do not.
5. The controls that do not work are RadioButtons, CheckBoxes and the
up/down arrow of the NumericUpDown (I can still type in data into the
TextBox-like part of the NumericUpDown).
6. Those that do are TextBoxes and ComboBoxes.
--------------------------
I suspect it has something to do with attempting to leave the
UserControl and returning back.
I tried by calling all conceivable methods of my UserControl, such as
Refresh(), Update(), Focus(), Show(), but none seemed to work.
What is the logic or state of affairs when the user tries to leave a
control, but the main form's OnClosing() event handler cancels the
closing?
Or, is there a better way to intercept the Closing of the UserControl
and to stay entirely within the UserControl?
Thanks