| | |
Remove Handler at Runtime
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 324
Reputation:
Solved Threads: 7
I want to after clicking on button2,after that if i click on button1 then msg is not displayed
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("sonia") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click RemoveHandler Button2.Click, AddressOf MYEVENTHandler End Sub Private Sub MYEVENTHandler(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub End Class
•
•
•
•
I want to after clicking on button2,after that if i click on button1 then msg is not displayed
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("sonia") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click RemoveHandler Button2.Click, AddressOf MYEVENTHandler End Sub Private Sub MYEVENTHandler(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub End Class
In your Form Load, setup the event handler for Button1. So, remove the statement Handles Button1.Click at the end of the Button1.Click procedure.
In your Form_Load place the following:
Addhandler Button1.Click, AddressOf MYEVENTHandler
In your MYEVENTHandler place the following code:
msgbox ("sonia")
In the Button2_Click, use the existing code you have, it will work.
Hope this helps.
Last edited by CodeDoctor; Sep 22nd, 2009 at 9:27 pm. Reason: typo
![]() |
Similar Threads
- C# Remove Textboxes During Runtime (C#)
- Changing and removing controls (VB.NET)
- Virus Changed Background (same problem as mrvin) (Viruses, Spyware and other Nasties)
- remove controls (VB.NET)
- Internet explorer keeps crashing (Viruses, Spyware and other Nasties)
- how to make a bitmap persistant (C++)
- Yellow flashing question mark/ "X".....GRRRRRRR (Viruses, Spyware and other Nasties)
- IE Syntax Error and Can“t browse some sites (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: how to restrict the user to enter only numbers
- Next Thread: Read Word File Data Store In Excel
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml





