C
Crumpet
I have a menu with a number of items that I want to handle their being
clicked on with just one handling method.
What I want is for the even handler method to recognize which menu item got
clicked. What is considered the best way to do that?
e.g.
private void miClick(object sender, EventArgs e)
{
string displaystring = e.ToString(); // e or sender - which do I use
and how ?? THANKS
MessageBox.Show(displaystring, "For your information", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
I can get some specific info but it seems rather convoluted.
If I click on the "About" menu item then the MessageBox will read:
"For your information
System.Windows.Forms.MenuItem, Items.Count: 0, Text: &About
OK"
Do I have to use some sort of regex or is there an easier way to identify
the specific menu item that was click?
Thanks
clicked on with just one handling method.
What I want is for the even handler method to recognize which menu item got
clicked. What is considered the best way to do that?
e.g.
private void miClick(object sender, EventArgs e)
{
string displaystring = e.ToString(); // e or sender - which do I use
and how ?? THANKS
MessageBox.Show(displaystring, "For your information", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
I can get some specific info but it seems rather convoluted.
If I click on the "About" menu item then the MessageBox will read:
"For your information
System.Windows.Forms.MenuItem, Items.Count: 0, Text: &About
OK"
Do I have to use some sort of regex or is there an easier way to identify
the specific menu item that was click?
Thanks