Re: Calling an event to a class in a different namespace
-
Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this
-
Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this
To fire event you can use the
MenuItem.PerformClick
method. To call it from the form you should expose a public method in thePanelMasterlist
class that fire the delete event, something like this:public void DeleteMasterList()
{
contextDeleteMasterList.PerformClick();
} -
Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this
Create a method that handles the action and call it from both the main form menu item and the panel context menu item
private void Delete()
{
// Do something
}protected void OnDeleteMenu(object sender, EventArg e)
{
Delete();
}protected void OnDeleteContextMenu(object sender, EventArg e)
{
Delete();
}
I know the language. I've read a book. - _Madmatt