ToolStripDropDownItem.HasDropDownItems 属性

定义

获取一个值,该值指示 ToolStripDropDownItem 是否有 ToolStripDropDown 控件与它关联。

public:
 virtual property bool HasDropDownItems { bool get(); };
[System.ComponentModel.Browsable(false)]
public virtual bool HasDropDownItems { get; }
[<System.ComponentModel.Browsable(false)>]
member this.HasDropDownItems : bool
Public Overridable ReadOnly Property HasDropDownItems As Boolean

属性值

如果 ToolStripDropDownItemToolStripDropDown 控件,则为 true;否则为 false

属性

示例

下面的代码示例演示如何查询 HasDropDownItems 属性以有条件地显示 ToolStripDropDownItem 控件。 此代码示例是为 ToolStripDropDownItem 类提供的一个更大示例的一部分。

// This method shows the drop-down for the first item
// in the form's ToolStrip.
private void showButton_Click(object sender, EventArgs e)
{
    ToolStripDropDownItem item = this.toolStrip1.Items[0] as ToolStripDropDownItem;

    if (item.HasDropDownItems)
    {
        item.ShowDropDown();
    }
}
' This method shows the drop-down for the first item
' in the form's ToolStrip.
 Private Sub showButton_Click( _
 ByVal sender As Object, _
 ByVal e As EventArgs) _
 Handles showButton.Click

     Dim item As ToolStripDropDownItem = CType(Me.toolStrip1.Items(0), ToolStripDropDownItem)

     If item.HasDropDownItems Then
         item.ShowDropDown()
     End If

 End Sub

适用于