MenuItem.BarBreak 属性

定义

获取或设置一个值,通过该值指示是将 MenuItem 放在新行上(对于添加到 MainMenu 对象的菜单项),还是放在新列中(对于 ContextMenu 中显示的子菜单项或菜单项)。Gets or sets a value indicating whether the MenuItem is placed on a new line (for a menu item added to a MainMenu object) or in a new column (for a submenu item or menu item displayed in a ContextMenu).

public:
 property bool BarBreak { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool BarBreak { get; set; }
member this.BarBreak : bool with get, set
Public Property BarBreak As Boolean

属性值

如果菜单项放在新行上或新列中,则为 true;如果菜单项保持在其默认位置,则为 falsetrue if the menu item is placed on a new line or in a new column; false if the menu item is left in its default placement. 默认值为 falseThe default is false.

属性

示例

下面的代码示例创建一个包含两个子菜单项的 MenuItemThe following code example creates a MenuItem with two submenu items. 两个子菜单项在水平方向上显示,而不是使用 BarBreak 属性垂直显示。The two submenu items are displayed horizontally instead of vertically using the BarBreak property.

public:
   void CreateMyMenus()
   {
      // Create three top-level menu items.
      MenuItem^ menuItem1 = gcnew MenuItem( "&File" );
      MenuItem^ menuItem2 = gcnew MenuItem( "&New" );
      MenuItem^ menuItem3 = gcnew MenuItem( "&Open" );
      // Set the BarBreak property to display horizontally.
      menuItem2->BarBreak = true;
      menuItem3->BarBreak = true;
      // Add menuItem2 and menuItem3 to the menuItem1's list of menu items.
      menuItem1->MenuItems->Add( menuItem2 );
      menuItem1->MenuItems->Add( menuItem3 );
   }
public void CreateMyMenus()
{
   // Create three top-level menu items.
   MenuItem menuItem1 = new MenuItem("&File");
   MenuItem menuItem2 = new MenuItem("&New");
   MenuItem menuItem3 = new MenuItem("&Open");
   // Set the BarBreak property to display horizontally.
   menuItem2.BarBreak = true;
   menuItem3.BarBreak = true;
   // Add menuItem2 and menuItem3 to the menuItem1's list of menu items.
   menuItem1.MenuItems.Add(menuItem2);
   menuItem1.MenuItems.Add(menuItem3);
}

Public Sub CreateMyMenus()
    ' Create three top-level menu items.
    Dim menuItem1 As New MenuItem("&File")
    Dim menuItem2 As New MenuItem("&New")
    Dim menuItem3 As New MenuItem("&Open")
    ' Set the BarBreak property to display horizontally.
    menuItem2.BarBreak = True
    menuItem3.BarBreak = True
    ' Add menuItem2 and menuItem3 to the menuItem1's list of menu items.
    menuItem1.MenuItems.Add(menuItem2)
    menuItem1.MenuItems.Add(menuItem3)
End Sub

注解

您可以使用 "BarBreak" 属性创建一个菜单,其中每个菜单项在水平位置相邻放置,而不是在垂直列表中放置。You can use the BarBreak property to create a menu where each menu item is placed next to each other horizontally instead of in a vertical list. 你还可以使用此属性来创建包含多行顶级菜单项的菜单栏。You can also use this property to create a menu bar that contains multiple rows of top-level menu items.

此属性与 Break 属性的不同之处在于,条形显示在将 Break 属性设置为 true的每个菜单项的左边缘。This property differs from the Break property in that a bar is displayed on the left edge of each menu item that has the Break property set to true. 仅当菜单项不是顶级菜单项时,才会显示此栏。The bar is only displayed when the menu item is not a top-level menu item.

适用于

另请参阅