ContextMenu problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Martel

    #1

    ContextMenu problem

    I am trying to create a dynamic flyout submenu off of a contextmenu.
    I can right click and get the base contextmenu ok.
    On the Popup event I add MenuItem's to the collection of one of the items so
    it has a flyout submenu when selected.
    If I try and add more than 1 item to the submenu it only shows up the first
    time.
    This same code works fine if it is part of a MainMenu but not with a
    ContextMenu.

    Has anyone seen this before? Have you found a work around?

    Here is a sample of the code that I use in the Popup event for the
    contextmenu.
    (mnuExisting is one of the menu items in the context menu)

    MenuItem[] aMi = new MenuItem[2];
    aMi[0] = new MenuItem("SubMe nu Item 1");
    aMi[1] = new MenuItem("SubMe nu Item 2");
    mnuExisting.Men uItems.Clear();
    mnuExisting.Men uItems.AddRange (aMi);

    This will work the first time the contextmenu it shown but the submenu
    doesn't show after that.
    If I change this to add an array of 1 it works every time.

    Thanks for any help.


  • AlexS

    #2
    Re: ContextMenu problem

    I think its because you use Popup event.
    Try to move menu creation code into MouseDown - for right-click. And maybe
    in related keypress handler if you use it.
    Also, you might try to recreate full context menu, not only submenu items.

    I create complete context menu on right-click. It never failed. But it was
    recreated on every right-click.

    HTH
    Alex

    "Brian Martel" <brian.martel_N O_SPAM_@_PLEASE _thermogalactic .com> wrote in
    message news:OODnfngoDH A.2512@TK2MSFTN GP09.phx.gbl...[color=blue]
    > I am trying to create a dynamic flyout submenu off of a contextmenu.
    > I can right click and get the base contextmenu ok.
    > On the Popup event I add MenuItem's to the collection of one of the items[/color]
    so[color=blue]
    > it has a flyout submenu when selected.
    > If I try and add more than 1 item to the submenu it only shows up the[/color]
    first[color=blue]
    > time.
    > This same code works fine if it is part of a MainMenu but not with a
    > ContextMenu.
    >
    > Has anyone seen this before? Have you found a work around?
    >
    > Here is a sample of the code that I use in the Popup event for the
    > contextmenu.
    > (mnuExisting is one of the menu items in the context menu)
    >
    > MenuItem[] aMi = new MenuItem[2];
    > aMi[0] = new MenuItem("SubMe nu Item 1");
    > aMi[1] = new MenuItem("SubMe nu Item 2");
    > mnuExisting.Men uItems.Clear();
    > mnuExisting.Men uItems.AddRange (aMi);
    >
    > This will work the first time the contextmenu it shown but the submenu
    > doesn't show after that.
    > If I change this to add an array of 1 it works every time.
    >
    > Thanks for any help.
    >
    >[/color]


    Comment

    Working...