ToolStripDropDownMenu Constructor

Definition

Initializes a new instance of the ToolStripDropDownMenu class.

public ToolStripDropDownMenu ();

Examples

The following code example demonstrates how to create and initialize a ContextMenuStrip control. For a full code listing, see How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls.

// This utility method creates a ContextMenuStrip control
// that has four ToolStripMenuItems showing the four 
// possible combinations of image and check margins.
internal ContextMenuStrip CreateCheckImageContextMenuStrip()
{
    // Create a new ContextMenuStrip control.
    ContextMenuStrip checkImageContextMenuStrip = new ContextMenuStrip();

    // Create a ToolStripMenuItem with a
    // check margin and an image margin.
    ToolStripMenuItem yesCheckYesImage = 
        new ToolStripMenuItem("Check, Image");
    yesCheckYesImage.Checked = true;
    yesCheckYesImage.Image = CreateSampleBitmap();

    // Create a ToolStripMenuItem with no
    // check margin and with an image margin.
    ToolStripMenuItem noCheckYesImage = 
        new ToolStripMenuItem("No Check, Image");
    noCheckYesImage.Checked = false;
    noCheckYesImage.Image = CreateSampleBitmap();

    // Create a ToolStripMenuItem with a
    // check margin and without an image margin.
    ToolStripMenuItem yesCheckNoImage = 
        new ToolStripMenuItem("Check, No Image");
    yesCheckNoImage.Checked = true;

    // Create a ToolStripMenuItem with no
    // check margin and no image margin.
    ToolStripMenuItem noCheckNoImage = 
        new ToolStripMenuItem("No Check, No Image");
    noCheckNoImage.Checked = false;

    // Add the ToolStripMenuItems to the ContextMenuStrip control.
    checkImageContextMenuStrip.Items.Add(yesCheckYesImage);
    checkImageContextMenuStrip.Items.Add(noCheckYesImage);
    checkImageContextMenuStrip.Items.Add(yesCheckNoImage);
    checkImageContextMenuStrip.Items.Add(noCheckNoImage);

    return checkImageContextMenuStrip;
}

Applies to

Produk Versi
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9