Edit

Share via


How to: Add Menu Items to a ContextMenuStrip

You can add just one menu item or several items at a time to a ContextMenuStrip.

To add a single menu item to a ContextMenuStrip

  • Use the Add method to add one menu item to a ContextMenuStrip.

    Me.contextMenuStrip1.Items.Add(Me.toolStripMenuItem1)  
    
    this.contextMenuStrip1.Items.Add(toolStripMenuItem1);  
    

To add several menu items to a ContextMenuStrip

  • Use the AddRange method to add several menu items to a ContextMenuStrip.

    Me.contextMenuStrip1.Items.AddRange(New _  
       System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItem1, _  
          Me.toolStripMenuItem2})  
    
    this.contextMenuStrip1.Items.AddRange(new
       System.Windows.Forms.ToolStripItem[] {  
          this.toolStripMenuItem1, this.toolStripMenuItem2});  
    

See also