How to display a context menu fully?

Hi, I am working on a web parts custom control which consists of a label,a list box and a context menu. I bounded the context menu to the list box such that when the user rightclicks on the list, the menu will appear. However, when the menu appears, it is blocked by the listbox. Hence only part of the menu is visible. How do I make the menu to be totally visible and to appear 'on top of' the listbox?

A code snippet is below:

list1.ID = "List1" 'List's ID
listitem1.Text = "Testing" 'List's items
listitem2.Text = "Event"
list1.Items.Add(listitem1)
list1.Items.Add(listitem2)
Me.Controls.Add(label1) 'Add the list as part of the custom ctrl

menu1.ID = "ContextMenu1"
menuitem1.Text = "Acknowledge" 'Menu Items
menuitem2.Text = "Testing"
menu1.ContextMenuItems.Add(menuitem1)
menu1.ContextMenuItems.Add(menuitem2)
menu1.BoundControls.Add(list1) 'Attatch menu to the list
Me.Controls.Add(menu1) 'Add the menu to the custom control

The code is in Visual Basic. Advice will be appreciated!

Comments

  • Hi,

    How are you? May be after a long time, you posted this query. I am in a similar situation. Do you got solution for this. Please let me know if you have any.

    Thanks,
    Satheesh M
  • seancampbellseancampbell Pennsylvania, USA
    Satheesh, Try calling .BringToFront() on your context menu

    Like this:
    [code]

    menu1.ID = "ContextMenu1"
    menuitem1.Text = "Acknowledge" 'Menu Items
    menuitem2.Text = "Testing"
    menu1.ContextMenuItems.Add(menuitem1)
    menu1.ContextMenuItems.Add(menuitem2)
    menu1.BoundControls.Add(list1) 'Attatch menu to the list
    Me.Controls.Add(menu1) 'Add the menu to the custom

    controlmenu1.BrintToFront() 'Ensure the context menu displays overtop other controls
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories