Let me start off by saying that I'm working in Visual Studio 2005, using Visual C#.
I've been trying to pass custom Event arguments to the Click event of a ToolStripMenuItem, but I can't figure it out.
I'm probably just doing it all wrong, hence why I'm coming here for help.
What I've done is the following:
First, I create a custom eventargs class
Expand|Select|Wrap|Line Numbers
- public class EventArgs<T> : EventArgs
- {
- public EventArgs(T value)
- {
- argValue = value;
- }
- private T argValue;
- public T Value
- {
- get { return argValue; }
- }
- }
Expand|Select|Wrap|Line Numbers
- void MenuItem_Click(object sender, EventArgs<string> e)
- {
- MessageBox.Show("YAY!");
- }
Expand|Select|Wrap|Line Numbers
- Item.Click += new EventHandler<EventArgs<string>>(MenuItem_Click)(this, new EventArgs<string>("test"));
Expand|Select|Wrap|Line Numbers
- Cannot implicitly convert type 'void' to 'System.EventHandler'
What am I doing wrong?
PS: Apologies for any flaws in my English, it's not my native language, so I might've made some weird sentences.