I've been looking for an answer for about an hour on Google but I did not found exactly what I'm looking for.
Basically, I have a static Helper class that helps perform many things I do frequently in my App. In this case, I have a method named "CreateDataContextMenu" that creates a context menu on a given TreeView control.
public static void CreateDataContextMenu(Form parent, TreeView owner, string dataType)
{ ... }
TreeView owner is the control in which I will associate my context menu.
Then later on I add a Click event to a MenuItem like this:
menuItemFolder.Click += new System.EventHandler(menuItemFolder_Click);
The problem I have here is that I want to pass "owner" and "dataType" as arguments to the menuItemFolder_Click event.
I tried the following:
menuItemFolder.Click += new System.EventHandler(menuItemFolder_Click(sender,e,owner,dataType));
(...)
private static void menuItemFolder_Click(object sender, System.EventArgs e, Treeview owner, string dataType)
{...}
But it doesn't work at all. It might be very naive of me to do it that way but I"m not very comfortable with event handler yet.
Any idea on how I could do that? My first guess is that I need to create my own EventHandler for this specific case. Am I going in the right direction with that?