E
eaguilar
Hi,
I am trying to dynamically generate a menu, based on entries on a text or
xml file. The text file contains the "tree" after which the menu will need to
be created. Something like the following:
Level 1
-- Level 2
-- Level 2
Level 1
-- Level 2
---- Level 3
I can read the file and generate each menu item definition, with the
corresponding "nesting", without a problem.
What I'm having difficulties with is deciding on how to handle the events
for each of the menu items. Generating the full menu dynamically would mean
having to create the event handlers dynamically, unless I have a fixed amount
of event handlers, which I'm not sure is the best approach. I might be wrong
here...
1. What's the best way to generate event handlers dynamically? I've read
about runtime IL generation, which makes sense but is a bit complex.
2. Using regular event handlers (hard coded), can I capture which of the
menu items is being clicked and what component is the menu being displayed
on? i.e., if the menu is being displayed after a right click on a button or a
picture box, can I: 1) know if it's the picture box or the button displaying
the menu? and 2) can I know what menu/sub menu is being clicked?
Any ideas will be greatly appreciated.
Thanks in advance,
</edwin>
I am trying to dynamically generate a menu, based on entries on a text or
xml file. The text file contains the "tree" after which the menu will need to
be created. Something like the following:
Level 1
-- Level 2
-- Level 2
Level 1
-- Level 2
---- Level 3
I can read the file and generate each menu item definition, with the
corresponding "nesting", without a problem.
What I'm having difficulties with is deciding on how to handle the events
for each of the menu items. Generating the full menu dynamically would mean
having to create the event handlers dynamically, unless I have a fixed amount
of event handlers, which I'm not sure is the best approach. I might be wrong
here...
1. What's the best way to generate event handlers dynamically? I've read
about runtime IL generation, which makes sense but is a bit complex.
2. Using regular event handlers (hard coded), can I capture which of the
menu items is being clicked and what component is the menu being displayed
on? i.e., if the menu is being displayed after a right click on a button or a
picture box, can I: 1) know if it's the picture box or the button displaying
the menu? and 2) can I know what menu/sub menu is being clicked?
Any ideas will be greatly appreciated.
Thanks in advance,
</edwin>