By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,811 Members | 785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,811 IT Pros & Developers. It's quick & easy.

"How to create click event handler dynamically for each submenuitem"

P: n/a
Hi,
I m developing a Windows application in which i want to create a
context menu, having variable number of submenus depending on the the
list in the file. I m able to create these submenus at runtime by
reading the file. But the problem is that there is no fixed count of
submenus and becaz of that i m not able to figure out "How to create
click event handler dynamically for each submenuitem"? Please help.
Thanks,
Nikki

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Assign the same click event to each menu option, then in the handler use the
name to determine which was clicked.

ie.
public void AllMenuOptions_Clicked(object sender, ...)
{
switch( ((Control)sender).Name).ToString())
{
case "mnuFile":
<whatever>
break;

case "mnuEdit":
<whatever>
break;
}
}

You can do more funky stuff with reflection but thats a different story.
"Nikki" <ap*********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hi,
I m developing a Windows application in which i want to create a
context menu, having variable number of submenus depending on the the
list in the file. I m able to create these submenus at runtime by
reading the file. But the problem is that there is no fixed count of
submenus and becaz of that i m not able to figure out "How to create
click event handler dynamically for each submenuitem"? Please help.
Thanks,
Nikki

Nov 17 '05 #2

P: n/a

Thanks Mr. Adam Barker.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.