Condividi tramite


ToolStripDropDownItem.DropDown Proprietà

Definizione

Ottiene o imposta l'oggetto ToolStripDropDown che verrà visualizzato quando si fa clic su ToolStripDropDownItem.

public:
 property System::Windows::Forms::ToolStripDropDown ^ DropDown { System::Windows::Forms::ToolStripDropDown ^ get(); void set(System::Windows::Forms::ToolStripDropDown ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))]
public System.Windows.Forms.ToolStripDropDown DropDown { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))>]
member this.DropDown : System.Windows.Forms.ToolStripDropDown with get, set
Public Property DropDown As ToolStripDropDown

Valore della proprietà

Un oggetto ToolStripDropDown associato all'oggetto ToolStripDropDownItem.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come assegnare un ContextMenuStrip controllo alla proprietà di DropDown un ToolStripDropDownItem controllo. Questo esempio di codice fa parte di un esempio più ampio fornito per la ToolStripDropDownItem classe .

// 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 });
}
' This utility method creates and initializes three 
' ToolStripDropDownItem controls and adds them 
' to the form's ToolStrip control.
Private Sub InitializeToolStripDropDownItems()
   Dim b As New ToolStripDropDownButton("DropDownButton")
   b.DropDown = Me.contextMenuStrip1
   AddHandler b.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler b.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler b.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Dim m As New ToolStripMenuItem("MenuItem")
   m.DropDown = Me.contextMenuStrip1
   AddHandler m.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler m.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler m.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Dim sb As New ToolStripSplitButton("SplitButton")
   sb.DropDown = Me.contextMenuStrip1
   AddHandler sb.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler sb.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler sb.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Me.toolStrip1.Items.AddRange(New ToolStripItem() {b, m, sb})
End Sub

Commenti

Se non ToolStripDropDown è associato ToolStripDropDownItema , una chiamata a CreateDefaultDropDown crea un controllo a discesa generico.

Nota

Se un controllo a discesa viene generato automaticamente, il che significa che gli elementi vengono aggiunti alla raccolta e quindi si imposta la DropDown proprietà su un controllo a discesa esplicito, si potrebbero perdere dati.

Si applica a