ToolStripDropDownItem.DropDown Property

Gets or sets the ToolStripDropDown that will be displayed when this ToolStripDropDownItem is clicked.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

[TypeConverterAttribute(typeof(ReferenceConverter))] 
public ToolStripDropDown DropDown { get; set; }
/** @property */
public ToolStripDropDown get_DropDown ()

/** @property */
public void set_DropDown (ToolStripDropDown value)

public function get DropDown () : ToolStripDropDown

public function set DropDown (value : ToolStripDropDown)

Not applicable.

Property Value

A ToolStripDropDown that is associated with the ToolStripDropDownItem.

If no ToolStripDropDown is associated with the ToolStripDropDownItem, a call to CreateDefaultDropDown creates a generic drop-down control.

NoteNote:

   If a drop-down control is automatically generated, which means that items are added to the collection, and you then set the DropDown property to an explicit drop-down control, you might lose data.

The following code example demonstrates how to assign a ContextMenuStrip control to a ToolStripDropDownItem control's DropDown property. This code example is part of a larger example provided for the ToolStripDropDownItem class.

// This utility method creates and initializes three 
// ToolStripDropDownItem controls and adds them 
// to the form's ToolStrip control.
private void InitializeToolStripDropDownItems()
{
    ToolStripDropDownButton b = new ToolStripDropDownButton("DropDownButton");
    b.DropDown = this.contextMenuStrip1;
    b.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    b.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    b.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    ToolStripMenuItem m = new ToolStripMenuItem("MenuItem");
    m.DropDown = this.contextMenuStrip1;
    m.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    m.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    m.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    ToolStripSplitButton sb = new ToolStripSplitButton("SplitButton");
    sb.DropDown = this.contextMenuStrip1;
    sb.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    sb.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    sb.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    this.toolStrip1.Items.AddRange(new ToolStripItem[] { b, m, sb });
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: