Xceed SmartUI for WinForms v3.6 Documentation
Using the SmartMenuBar SmartControl
Welcome to Xceed SmartUI for WinForms v3.6 > Basic Concepts > SmartControls > SmartMenuBar > Using the SmartMenuBar SmartControl

This topic demonstrates how to use the SmartMenuBar SmartControl using both the designer and code. The code is provided in a sequential order and can be cut and pasted into your application step-by-step.

Basic steps

To use the SmartMenuBar in your application, the following steps must be performed:

  1. Add the SmartMenuBar control to your form.
     

If you would prefer to add the SmartMenuBar SmartControl to your form programmatically, the following code can be used:

using Xceed.SmartUI;

using Xceed.SmartUI.Controls.MenuBar;

SmartMenuBar bar = new SmartMenuBar();

this.Controls.Add( bar );
  1. Double click on the New MainMenuItem menu or click on the drop down arrow to add MainMenuItem SmartItems. 

To add MainMenuItem SmartItems programmatically to the SmartMenuBar, you can use the following code:

bar.Items.Add( "first" );

bar.Items.Add( "second" );

bar.Items.Add( "third" );

bar.Items.Add( "fourth" );
  1. Add the desired sub SmartItems to each MainMenuItem. 

If you want to add items other than menu items, you can click on the drop down arrow and select the SmartItem to add.  



To add SmartItems programmatically to the MainMenuItem SmartItems, you can use the following code: 

We will start by adding a PopupMenuItem SmartItem that contains 2 CheckMenuItem SmartItems to the second MainMenuItem.

PopupMenuItem popMenu = new PopupMenuItem( "Popup Menu" );

popMenu.Items.Add( new CheckMenuItem( "First checkmenu" ) );

popMenu.Items.Add( new CheckMenuItem( "Second checkmenu" ) );

bar.Items[ 1 ].Items.Add( popMenu );

Next, we can add a ProgressPanel SmartItem to both the PopupMenuItem SmartItem and the SmartMenuBar SmartControl:

bar.Items.Add( new ProgressPanel() );

popMenu.Items.Add( new ProgressPanel() );

When you run your application, you end up with an XP-style menubar quite similar to the one found in some Microsoft applications, like Visual Studio .NET or Office XP:    

Things you should consider