| | |
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
Views: 246 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove richtextbox right-to-left save search searchvb.net serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





