Getting info on C# menu items after a click
Another question from a C# newbie- I would like to use a single function
to respond to a list of choices offered in the menu. When I run in debug
mode I can hover the mouse over sender and it is clear that sender has the
information I need, both the index of the item in the menu and the text
associated with it. However, I have not figured out how to write code in a
way that I get what I am looking for. The following does not compile:
int device;
private void myMenuItemInputClick(object sender, EventArgs e)
{
device = sender.Index;
}
What I see when I put a breakpoint on myMenuItemInputClick and put the
mouse over sender is:
sender {Windows.System.Forms.MenuItem, Items.Count:0, Text:Stereo Mix
(Realtek High Defini}
Moving the mouse over the "+" sign so it becomes a "-" and a list of debug
statements drops down shows that there is an item Index that is exactly
what I want. How do I write the code that will get the item I'm looking
for?
No comments:
Post a Comment