This documentation is archived and is not being maintained.

ToolStripDropDownMenu Constructor

Initializes a new instance of the ToolStripDropDownMenu class.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ToolStripDropDownMenu()

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.

    return checkImageContextMenuStrip;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0