Export (0) Print
Expand All

MenuItem.BarBreak Property

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).

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

public bool BarBreak { get; set; }
/** @property */
public boolean get_BarBreak ()

/** @property */
public void set_BarBreak (boolean value)

public function get BarBreak () : boolean

public function set BarBreak (value : boolean)

Not applicable.

Property Value

true 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. The default is false.

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.

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.

The following code example creates a MenuItem with two submenu items. 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 = 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 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.set_BarBreak(true);
    menuItem3.set_BarBreak(true);

    // Add menuItem2 and menuItem3 to the menuItem1's list of menu items.
    menuItem1.get_MenuItems().Add(menuItem2);
    menuItem1.get_MenuItems().Add(menuItem3);
} //CreateMyMenus

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, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft