Jon Rothlander <[EMAIL PROTECTED]> wrote:

Are you Jon or Greg?

> I'm building a menu dynamically at runtime based on an XML document.  I have
> something like...
> 
> MenuItem Text="Menu 1" Tag="Form1"
>         MenuItem Text="Menu 1.1" Tag="Form2"

> I wrote some basic logic to load these into a menu strip as individual menu
> strip items.  This work fine!  However, now I want to create a function to
> process the items when they are clicked on.

Attach a delegate to Click event of the items as you're adding them. The
target method of the delegate can be the same for each item, effectively
attaching the same piece of code to every item.

> If I cannot do this, then I will need to wire up an event for EACH of the
> menu items as I add them to the menu.  I'm not sure how to do that either.
> How do you add events to items that you create dynamically?

Perhaps you'd find a tutorial on events and delegates useful:

http://www.softsteel.co.uk/tutorials/cSharp/lesson16.html

> Best regards,
> Greg

Or Jon?

-- Barry

-- 
http://barrkel.blogspot.com/

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to