You can create toolbars in either design-time using the DotNetBar Windows Forms designer or in run-time by writting the code. You can always create the toolbar in design-time and explore the InitializeComponent method that is automatically created on the form and which will have all the code that is needed to create the toolbar that you actually see on the form.
Creating toolbar from code

To create the toolbar from code follow these steps:

  1. Create new Bar object
  2. Add the Bar object to the DotNetBarManager.Bars collection using the Add method
  3. Set the DockSide property of the Bar object to eDockSide.Top
  4. Create ButtonItem object and assign name and optional text to it
  5. Set the Image or ImageIndex property to the image you want displayed on the button. Note that if you decided to use ImageIndex property you will have to assign the ImageList with images to the DotNetBarManager.Images property
  6. Add that ButtonItem object to the Bar.Items collection using Add method
  7. To create drop-down menu or toolbar for this item add new ButtonItem objects to the ButtonItem SubItems collection using the Add method.
  8. Repeat steps 4-7 to create additional toolbar buttons and/or drop-down menu/toolbar

See following code for sample implementation. Also review the BarFromCode sample shipped with DotNetBar for working sample and full source code.

VB:

Imports DevComponents.DotNetBar
        .
        .
        .
        ' Create a new Bar
        Dim bar As Bar = New Bar("Standard")
        bar.CanHide = True
        bar.GrabHandleStyle = eGrabHandleStyle.StripeFlat
        bar.WrapItemsDock = True
        bar.WrapItemsFloat = False
        m_DotNetBar.Bars.Add(bar)
        bar.DockSide = eDockSide.Top
 
        ' Add Items to it
        Dim item, fileItem As ButtonItem
        ' New
        item = New ButtonItem("bNew")
        item.ImageIndex = 0
        item.Text = "&New"
        item.Shortcuts.Add(eShortcut.CtrlN)
        item.Category = "Standard"
        bar.Items.Add(item)
        m_DotNetBar.Items.Add(item.Copy())  ' This will create Category Entry
        .
        .
        .
        bar.RecalcLayout()

C#:

 using DevComponents.DotNetBar;
         .
         .
         .
         // Create a new Bar
         Bar bar=new Bar("Standard");
         bar.CanHide=true;
         bar.GrabHandleStyle=eGrabHandleStyle.StripeFlat;
         bar.WrapItemsDock=true;
         bar.WrapItemsFloat=false;
         m_DotNetBar.Bars.Add(bar)
         bar.DockSide=eDockSide.Top;
 
         // Add Items to it
         ButtonItem item, fileItem;
         // New
         item=new ButtonItem("bNew");	
         item.ImageIndex=0;
         item.Text="&New";
         item.Shortcuts.Add(eShortcut.CtrlN);
         item.Category="Standard";
         bar.Items.Add(item);	
         m_DotNetBar.Items.Add(item.Copy());		// This will create Category Entry
         .
         .
         .
         bar.RecalcLayout();

Related posts:

  1. How to Create Popup Menu or Toolbar Using Code
  2. How to Create Menu Using Code
  3. How to Create Context Menus
  4. How To Create NavigationPane Buttons Using Code
  5. How to Create/Remove Tabs Using Code