473,396 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Some Controls Do Not Work After OnClosing is Cancelled

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
Jul 9 '08 #1
2 1666
Oops.

During my research, I had turned on the UserControl OnValidating()
event and had set e.Cancel = true, but saw no visible results at that
time.

Just now, I discovered that I had left e.Cancel = true, within
UserControl.OnValidating()

Problem is solved, but a curiosity: Why did some controls work and
others did not when I set:

UserControl.OnValidating()
{
e.Cancel = true;
}
Jul 9 '08 #2
On Jul 9, 3:53*pm, richard.mart...@raymondjames.com wrote:
Oops.

During my research, I had turned on the UserControl OnValidating()
event and had set e.Cancel = true, but saw no visible results at that
time.

Just now, I discovered that I had left e.Cancel = true, within
UserControl.OnValidating()

Problem is solved, but a curiosity: Why did some controls work and
others did not when I set:

UserControl.OnValidating()
{
* * e.Cancel = true;

}- Hide quoted text -

- Show quoted text -
Hi,

Maybe those controls were disposed before you cancel the closing.
Jul 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Norman Fritag | last post by:
Hi there I have avoided to use active x controls because I thought they are causing more problems then they are doing any good. I a new application I would want to use the tree and list view...
1
by: Alex Bink | last post by:
Hi, Anyone knows how to prevent the validating event of a control to be fired when the user clicks the close button? The OnClosing event of the form seems to be to late and setting the form's...
9
by: Greg | last post by:
Binding Manager & dataset - won't add record I've got an untyped dataset with controls bound through code. The user can select a question number from a bound combobox, and the question number and...
5
by: gsb58 | last post by:
Hi! In my application I have code that will give the user a choice when he click's the close button on the ToolBar1. However, when he clicks the close button of the form, the form will shut...
1
by: Phill W. | last post by:
Has any come across a situation where, in a Form-derived .. er .. Form, the Event Arguments passed to OnClosing /already/ have their Cancel argument set to True? Protected Overrides Sub...
5
by: Ole | last post by:
The Application.Exit (called from a worker thread) method doesn't cause the OnClosing event handler to be run - is that a default behaviour??? If so - what should I do to properly close all threads...
0
by: shumaker | last post by:
What's the difference between overriding OnFormClosing or simply wiring up my own event handler OnClosing that is not declared as override?
5
by: AMBLY | last post by:
Hi everyone! Could someone help me with this, please? I run Access2000 on XP Have created a Report. Have placed a button on a form to email the report Works fine - email is generated, ready...
4
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel As Integer) MsgBox "There are no errors in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.