Share via


ModulePage.ContextMenuStrip Property

Definition

Gets or sets the shortcut menu for the page.

public:
 virtual property System::Windows::Forms::ContextMenuStrip ^ ContextMenuStrip { System::Windows::Forms::ContextMenuStrip ^ get(); void set(System::Windows::Forms::ContextMenuStrip ^ value); };
public override System.Windows.Forms.ContextMenuStrip ContextMenuStrip { get; set; }
member this.ContextMenuStrip : System.Windows.Forms.ContextMenuStrip with get, set
Public Overrides Property ContextMenuStrip As ContextMenuStrip

Property Value

A ContextMenuStrip object, or null if a value has not been assigned.

Examples

The following example creates a shortcut menu and populates it with controls.

void initCntxMenu() {

    ContextMenuStrip = new ContextMenuStrip();
    InitializeComponent2();
}
internal partial class DemoPage : ModulePage {
    private ToolStripMenuItem _tsm1;
    private ToolStripMenuItem _tsm2;
    private ToolStripMenuItem _tsm3;

    private void InitializeComponent2() {
        _tsm1 = new System.Windows.Forms.ToolStripMenuItem();
        _tsm2 = new System.Windows.Forms.ToolStripMenuItem();
        _tsm3 = new System.Windows.Forms.ToolStripMenuItem();
        // 
        // contextMenuStrip1
        // 
        ContextMenuStrip.Items.AddRange(
            new System.Windows.Forms.ToolStripItem[] {
        _tsm1,
        _tsm2,
        _tsm3});
        ContextMenuStrip.Name = "contextMenuStrip1";
        ContextMenuStrip.Size = new System.Drawing.Size(180, 70);
        // 
        // _tsm1
        // 
        _tsm1.Name = "_tsm1";
        _tsm1.Size = new System.Drawing.Size(179, 22);
        _tsm1.Text = "_tsm1 info";
        _tsm1.Click += new EventHandler(_tsm1_Click);
        // 
        // _tsm2
        // 
        _tsm2.Name = "_tsm2";
        _tsm2.Size = new System.Drawing.Size(179, 22);
        _tsm2.Text = "_tsm2 any questions?";
        // 
        // _tsm3
        // 
        _tsm3.Name = "_tsm3";
        _tsm3.Size = new System.Drawing.Size(179, 22);
        _tsm3.Text = "_tsm3 the end";
        // 
        // Form1
        // 
        ContextMenuStrip.ResumeLayout(false);

    }

    void _tsm1_Click(object sender, EventArgs e) {
        MessageBox.Show("congrad", sender.ToString());
    }
}

Applies to