473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suspending all control events for a form

I have a form with a bunch (maybe 30) different controls that generate events
when changed, clicked, etc. The various event handlers in turn might change
some of these controls, thereby causing other events, which is not what I
want. So, is there a simple way to turn off all events for a particular
form, then turn them all back on? I know I can individually turn them off
and on by using -= and += but that seems like a pretty brutal thing to have
to do. There should be some simple soultion like the equivalent of "disable
interrupts" and "enable interrupts".

Thanks,
Ray
Jun 14 '07 #1
3 1883
Ray,

No, there isn't. You have to be mindful of how the actions taken up in
event handlers can trigger new events to be fired. You either have to
remove the event handlers at the appropriate time, as you stated, or use
state flags to indicate what events you are currently handling, and prevent
reentrancy.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ray Mitchell" <Ra************ *****@MeanOldTe acher.comwrote in message
news:7E******** *************** ***********@mic rosoft.com...
>I have a form with a bunch (maybe 30) different controls that generate
events
when changed, clicked, etc. The various event handlers in turn might
change
some of these controls, thereby causing other events, which is not what I
want. So, is there a simple way to turn off all events for a particular
form, then turn them all back on? I know I can individually turn them off
and on by using -= and += but that seems like a pretty brutal thing to
have
to do. There should be some simple soultion like the equivalent of
"disable
interrupts" and "enable interrupts".

Thanks,
Ray

Jun 14 '07 #2
Some controls offer BeginUpdate / EndUpdate pairs that sometimes do
this - but in general a form-level "isUpdating " variable (bool) might
be in order. Not very elegant, but it works.

Marc
Jun 14 '07 #3
Hi here,
Easy stuff
Have a bool or use the control's tag (if some control events still want to
fire)
--
cheers,
RL
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:ee******** *****@TK2MSFTNG P02.phx.gbl...
Ray,

No, there isn't. You have to be mindful of how the actions taken up in
event handlers can trigger new events to be fired. You either have to
remove the event handlers at the appropriate time, as you stated, or use
state flags to indicate what events you are currently handling, and
prevent reentrancy.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ray Mitchell" <Ra************ *****@MeanOldTe acher.comwrote in message
news:7E******** *************** ***********@mic rosoft.com...
>>I have a form with a bunch (maybe 30) different controls that generate
events
when changed, clicked, etc. The various event handlers in turn might
change
some of these controls, thereby causing other events, which is not what I
want. So, is there a simple way to turn off all events for a particular
form, then turn them all back on? I know I can individually turn them
off
and on by using -= and += but that seems like a pretty brutal thing to
have
to do. There should be some simple soultion like the equivalent of
"disable
interrupts" and "enable interrupts".

Thanks,
Ray


Jun 14 '07 #4

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

Similar topics

3
4161
by: Not Me | last post by:
Hi, Just trying to get my head around tab controls, is there anywhere which would describe the structure of how they work? I seem to be ok so far, being able to check which page I'm on etc... but I'm at a loss when trying to access controls inside the tabs. If I try to access the form directly (!...etc.) I get an error that the form...
5
2890
by: MLH | last post by:
Having identified a A97 bug in which acDialog causes undesirable side effects processing the opened form, I would like to replace the following code running in MyForm ... DoCmd.OpenForm "frmVehicleChooserForm", , , , , acDialog .... (more code I want to run after suspension) With this new approach... DoCmd.OpenForm...
2
3608
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
1
2271
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP message but this only goes to the form and I want it in the user control that maybe very much removed from the form's knowledge; i.e. the form may...
1
2270
by: Mohammad Hashemian | last post by:
Hello I'm writing an application and in one of it's forms I should dispose all existing controls, create and initialize some new controls and then add them to the form. so the form's appearance will be changed. But during this transition, when I add a control to the form, that control will be drawn momentarily. I want to know how can I...
9
5104
by: Rob | last post by:
When a custom control is used within a form, that control does not get events directly. I've run into this a couple times with both mouse and keyboard events. Ex: A custom control inherits from UserControl (or Panel, etc). If that particular control is being edited, it IS possible to assign handlers and get events. However, when the...
5
7655
by: | last post by:
I have a user control (tag) made up up 9 smaller user controls (minitag). I have a panel on a form that is being populated with 81 of the tag controls in a grid configuration. Even though I am using Suspend Layout, I still see the controls getting drawn as they are added to the panel. I've tried suspending the layout of the form, of the...
12
2303
by: Dave | last post by:
Hi all, I have an application which has some worker threads which often have to stop and wait for some further information from other threads. These pauses will often take a long time (a couple of minutes) and I want the thread to be able to begin work ASAP once the new information arrives so Thread.Sleep isn't the best solution. In .NET...
5
2290
by: Uzi | last post by:
Hi all, I have a thread which is running a long method in a third party component (witch is a com object and accessed via interop). I need to be able to suspend this thread. the thread.Suspend() method is deprecated in .NET 2.0 the AutoResetEvent and similar are not good for me since my thread is running an external method which I cannot...
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.