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

C#: How to remove delegation of a ToolBarButton's click event...

Hi, everybody...

I'm developing a c# windows application where my app has more than 2 forms in it. i've placed some toolbarbuttons on it. I've associated toolbarbuttons click events to it. Now what i need is to remove the associated methods of those tbbtns on some condition. I'm able to add delegates to those btns at any moment but i have no idea how to remove those delegations...

Any help is appriciable...

Thanks in advance.

Saravanan Krishnan
Apr 24 '08 #1
3 1664
balame2004
142 100+
Hi, everybody...

I'm developing a c# windows application where my app has more than 2 forms in it. i've placed some toolbarbuttons on it. I've associated toolbarbuttons click events to it. Now what i need is to remove the associated methods of those tbbtns on some condition. I'm able to add delegates to those btns at any moment but i have no idea how to remove those delegations...

Any help is appriciable...

Thanks in advance.

Saravanan Krishnan

Hello Saravanan,

You can just remove delegate.

Following is a sample that describes how to remove an event delegate.

Expand|Select|Wrap|Line Numbers
  1. //delegate is added for button click event
  2. this.button2.Click += new System.EventHandler(this.button2_Click);
  3.  
  4. //delegate for button click event is removed
  5. this.button2.Click -= new System.EventHandler(this.button2_Click);
  6.  

- Balaji U
Apr 24 '08 #2
hey bala,

i've did same thing to remove the button's association with the event handler method. that is

btn.click -= new eventhandler(mybtn_click);

but when the other form is opened i execute the above mentioned line. but even then when the same button in the current form(newly opened) is clicked, the event handler method present in the previously opened form gets executed and then the newly opened forms method gets executed.

I Conform that "[btn.click -= new eventhandler(mybtn_click);"] gets executed, but then also mybtn_click() method is called first. How is this possible after removing the delegation for that btn and method...

if u dont understand this reply u can ask for the code as well...
Apr 24 '08 #3
balame2004
142 100+
hey bala,

i've did same thing to remove the button's association with the event handler method. that is

btn.click -= new eventhandler(mybtn_click);

but when the other form is opened i execute the above mentioned line. but even then when the same button in the current form(newly opened) is clicked, the event handler method present in the previously opened form gets executed and then the newly opened forms method gets executed.

I Conform that "[btn.click -= new eventhandler(mybtn_click);"] gets executed, but then also mybtn_click() method is called first. How is this possible after removing the delegation for that btn and method...

if u dont understand this reply u can ask for the code as well...

Hello,

Please provide me comple source code so I can able to look into your problem.

- Balaji
Apr 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jacob | last post by:
Hello All, I am trying to serve out some content via IIS that is hosted on a remote fileserver, and am unable to get the delegation working correctly. Our setup is as follows: Local LAN...
1
by: mathon | last post by:
Hello, could anybody explain me the advantages and disadvantages of delegation and the advantages and disadvantages using event-listeners? - both related to the treatment of events. thanks in...
9
by: Charles Law | last post by:
I have a form on which user controls are placed at runtime. When a control is added to the form a handler is added for an event that a high-level object raises, which must be handled by the new...
4
by: Ahmed | last post by:
Hi everyone, Is there a way to add a toolbarbutton with dropdown menu similar to the mail button in IE? In another word, when the chevron is part of the button not beside it. Thanks Ahmed
0
by: lottoman | last post by:
Hello all, I am trying to draw a triangle on a toolbarbutton to simulate a drop down button without having the extra button beside my drop downbutton. I was successfully able to draw the...
1
by: Michel Vanderbeke | last post by:
Hello, Is it possible to use a Toolbar Button as a toggle, so that one click shows a form and a second click closes it again? MAny thanks and greetings, Michel
5
by: =?Utf-8?B?TWF5ZXI=?= | last post by:
Hi, I'm using two form classes and I would like all methods of the second class (the child class) to be managed by the first class (the main class). Is delegation the best solution for me? If so,...
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
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
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...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.