locked
how to add toolstripitem to the top of contextmenustrip? RRS feed

  • Question

  • Hi,folks

    I have successfully create toolstripitems dynamically, but if I add them to the contextmenustrip, they are added at the bottom of the strip. My question is how to add to the top of the strip instead? I couldn't find any information on the net.

    dim item1 as toolstripMenuItem
    item1= New ToolStripMenuItem("1")
    Me.ContextMenuStrip2.Items.Add(item1)



    Your help is greatly appreciated.


    Tigerwood2006
    Monday, May 11, 2009 1:48 AM

Answers

  • use Insert and you can specify an Index. So to add at the top specify Index of 0

    Dim item1 As ToolStripMenuItem
    
            Dim item2 As ToolStripMenuItem
    
            Dim item3 As ToolStripMenuItem
    
            item1 = New ToolStripMenuItem("Here")
    
            item2 = New ToolStripMenuItem("There")
    
            item3 = New ToolStripMenuItem("Everywhere")
    
    
    
            Me.ContextMenuStrip1.Items.Add(item1)
    
            Me.ContextMenuStrip1.Items.Add(item2)
    
    
    
            ContextMenuStrip1.Items.Insert(0, item3)
    
    
    • Edited by jwavila Monday, May 11, 2009 6:25 AM edit
    • Marked as answer by Tigerwood2006 Monday, May 11, 2009 6:37 AM
    Monday, May 11, 2009 6:05 AM