Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I am working on a window application (written using Vb.net).In the main form Load event another form 'frmcrew_managment' is also loaded.In this stage for RefreshClick event of Main form attaches 'Refreshadata' method ( handler) of 'frmcrew_managment' . As a result after the main form is loaded it's RefreshClick Event has the address of method of 'frmcrew_managment'. Now in the main form one of Menu options is OpenAdjustment (frmOpenAdjustment ) . So onclick of OpenAdjustment option, in it's form load (for frmOpenAdjustment ) I need to attach RefreshGriddata Method (of frmOpenAdjustment) to RefreshClick event of Main Form sothat when user clicks Refresh on main screen RefreshGriddata Method of frmOpenAdjustment is called. But now what is happening Refreshadata of frmcrew_managment is also getting called. So to solve this I need to remove all event handler from RefreshClick event of main Form before adding event handler RefreshGriddata of frmOpenAdjustment . So what is the way to removed all event handler from an event (RefreshClick )of main form?

here requirement is that by default in all cases Refreshclick of main form should be handled by Refreshadata of frmcrew_managment but when frmOpenAdjustment is loaded from menu option Refreshclick of main form should be handled by RefreshGriddata of frmOpenAdjustment

What I have tried:

Private _parent As frmMainAlt
Private _Me As frmOpenAdjustmentsAlt
Private _crewMgt As frmCrewManagement

_parent = parent


RemoveHandler _parent.RefreshClick, AddressOf _crewMgt.RefreshData

AddHandler _parent.RefreshClick, AddressOf refreshgrid
Posted
Updated 5-Apr-18 12:04pm
v2
Comments
Ralf Meier 8-Apr-18 14:57pm    
Your description is little bit confuse (for me).
What I understood is : you have one Form where you Show a a time another Form. I suggest that you remove a that time the Handler from the 1st Form and assign it to the 2nd Form.
Please note : the 1st Form is not the Parent for the 2nd Form. I suppose that this could be the mistake ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900