Add Menu Items Dynamically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom Bean

    #1

    Add Menu Items Dynamically

    Is it possible to dynamically add items to a menu and use one event handler
    for click events?

    If so, how do you detect which of the new items was clicked?

    Thanks,
    Tom


  • Tobin Harris

    #2
    Re: Add Menu Items Dynamically

    [color=blue]
    > Tom Bean wrote:[/color]
    [color=blue]
    > In the handling routine, you'll be passed an object. Cast this object to
    > a MenuItem. You can then use any number of properties to distinguish
    > between various MenuItems.[/color]

    A personal favourite is to use the "Tag" property of a menu to store enough
    information (such as a string) which is used to interpret the the menu
    click. I usually use the Magic library for menus (www.dotnetmagic.com), but
    I'm assuming that the standard .NET menus have this also (it's common to all
    [Control]s as far as I know.

    HTH

    Tobin
    [color=blue]
    > --
    > There are 10 kinds of people. Those who understand binary and those who
    > don't.
    >
    > http://code.acadx.com
    >
    >[/color]


    Comment

    Working...