473,385 Members | 1,640 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,385 software developers and data experts.

disable event handler

Hi,

Is there a way to disable an event handler, like a clik on a button
at a certain stage of the program.
Thanks in Advance
Nov 16 '05 #1
2 22006
> Is there a way to disable an event handler, like a clik on a button
at a certain stage of the program.


there are several possibilities here.

you could for example add a boolean control variable to your class and
inside the event handler test the variable:

void bt_Click(...)
{
if ( controlVariable )
{
// handle the event
}
}

you could also just remove the delegate from the event:

bt.Click -= new EventHandler( eventHandler );

and add it again when necessary:

bt.Click += new EventHandler( eventHandler );

regards,
Wiktor Zychla
Nov 16 '05 #2
Similar to the way you add an event handler, you can easly remove it by
using -=

Enable event handler
this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);

Disable event handler
this.btnBrowse.Click -= new System.EventHandler(this.btnBrowse_Click);
Hope that helps
Rob Vretenar [imason inc.]

Nov 16 '05 #3

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

Similar topics

8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
5
by: Ivan | last post by:
I am used to VB6 and am not sure how to do this in Vstudio .NET. I have a main form which calls other forms. I want to disable that main form while other ones are called. I tried hiding it and...
2
by: Lee | last post by:
Hi, I'd like to disable an event handles. How to perform that? Thanks
7
by: Scott Emick | last post by:
How can I disable events for the controls on a form? I tried setting the form's enable property to false, but that doesn't stop events from firing on its controls. I need to temporarily disable...
4
by: Buddy Ackerman | last post by:
If I put client side code to disable a button (so that a user doesn't click it twice and double post the form) then teh button doesn't get posted with the form and the button's server-side click...
2
by: khng | last post by:
How to disable the copy/drag event for some selected textfield as I want the user to key in instead of copy or drag the required information. For IE, I done it with the onPaste and onDragEnter...
17
by: dan_williams | last post by:
I have the following test web page:- <html> <head><title>Test</title> <script language="Javascript"> <!-- function fnTR() { alert("TR"); }
3
by: Richard Lewis Haggard | last post by:
Is there an easy way to disable the hotkey sequence Control F4 or otherwise prevent the action from killing off MDI child windows in VS05/WinForms 2? I've already figured out how to get rid of the...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.