473,563 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remove Handler.. & Add Handler...

VJ
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both
the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove
Handler not removing the old method and adding a new one for the same click
event. Anybody have ideas??

Thanks
VJ
Nov 20 '05 #1
5 4081
It doesent remove the method, it simply attaches/removes the method to the
event.

Regards - OHM
"VJ" <vi********@yah oo.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove Handler not removing the old method and adding a new one for the same click event. Anybody have ideas??

Thanks
VJ

Nov 20 '05 #2
I tried this out, both Labels have their clicks serviced until button one is
pressed, then only label2 works.
\\
Private Sub Label1_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Label1.Click

MessageBox.Show ("Label1.Clicke d")

End Sub

Private Sub Label2_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Label2.Click

MessageBox.Show ("Label2.Clicke d")

End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

RemoveHandler Label1.Click, AddressOf Label1_Click

End Sub
//
Regards - OHM


"VJ" <vi********@yah oo.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove Handler not removing the old method and adding a new one for the same click event. Anybody have ideas??

Thanks
VJ

Nov 20 '05 #3
* "VJ" <vi********@yah oo.com> scripsit:
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both
the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove
Handler not removing the old method and adding a new one for the same click
event.


What's 'Condition1' and 'Condition2'? Your code should work.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
VJ
Its just a whether a menu is checked or not... that is it.. The code does
not work.. I tried possibilities I know.. but it keeps the click event..

VJ

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:e5******** ******@tk2msftn gp13.phx.gbl...
* "VJ" <vi********@yah oo.com> scripsit:
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove Handler not removing the old method and adding a new one for the same click event.


What's 'Condition1' and 'Condition2'? Your code should work.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5
VJ
What happens if I do this?.. is there 2 refrences in memory?

AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem

Thanks
VJ

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:e5******** ******@tk2msftn gp13.phx.gbl...
* "VJ" <vi********@yah oo.com> scripsit:
Here is snippet of my problem

IF Condition1 then
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem
AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
elseif Condition2 then
AddHandler lblCntrl.Click, AddressOf lbl_ShowItem
RemoveHandler lblCntrl.Click, AddressOf lbl_ShowMaker2
end if

After the above block is executed I try to click on the label.. I have both the "lbl_ShowIt em" and "lbl_ShowMaker2 " methods executed. I had to go
include the same IF check inside each method to prevent... Why is the Remove Handler not removing the old method and adding a new one for the same click event.


What's 'Condition1' and 'Condition2'? Your code should work.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #6

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

Similar topics

9
2666
by: middletree | last post by:
I have a page which takes data in an HTML table, and exports it to an Excel file. It works fine, but I want several things about the spreadsheet to look different from the HTML version. Things like fonts and colors. I think I can use a style sheet for the latter, but I haven't figured out how to remove hyperlinks from some of the items. On the...
7
2600
by: Kieran Simkin | last post by:
Hi all, I'm having some trouble with a linked list function and was wondering if anyone could shed any light on it. Basically I have a singly-linked list which stores pid numbers of a process's children - when a child is fork()ed its pid is added to the linked list. I then have a SIGCHLD handler which is supposed to remove the pid from the...
3
7537
by: Franco, Gustavo | last post by:
How can I remove all event handler from one event without do -=? I won't explain why because is too long, and that the only option left I have right now. I have one event declared for: AppDomain.CurrentDomain.AssemblyResolve += XFUNCTION I need to remove all event handlers for the event AssemblyResolve in the
3
1611
by: Peter Oliphant | last post by:
In general, some controls can have events handlers attached to them, typically via the += operator. How does one remove an event handler added this way? Or, just as good for my purposes, how can one remove all event handlers attached?
4
8704
by: Charles Law | last post by:
Is there a way to dynamically remove an event handler from an event without knowing the name of the handler? For example, how can ClassB remove the handler without knowing the name, or how many handlers there are? <code> Public Class ClassA Private m_ClassB As New ClassB
10
12523
by: Franky | last post by:
How Remove All Handler on a event? Like remove all handler on the myButton.Click. Thanks ______________________________ Franky FrankyPDA_NOSPAM_@hotmail.com
8
2792
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as...
0
5465
by: dolittle | last post by:
Hi, I'm embedding a last.fm flash widget. I want to be able to remove it from the page using javascript. I've tried to delete the html element that contains the code but it keeps playing in IE. In FF it stops playing but I can't tell if it is removed or not. Can I do it in javascript or maybe I need a FLASH script to do it?
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
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
7948
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
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2082
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
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
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.