ICreate.Controls.Bars Send comments on this topic.
ButtonBar Class
See Also  Members   Example 
ICreate.Controls.Bars Namespace : ButtonBar Class






ButtonBar is a tool bar which can contain any number of ButtonBarButton and ButtonBarSeparator items.

Object Model


Syntax

Visual Basic (Declaration) 
Public Class ButtonBar 
   Inherits Bar
   Implements IMouseEventProcessor 
Visual Basic (Usage)Copy Code
Dim instance As ButtonBar
C# 
public class ButtonBar : Bar, IMouseEventProcessor  
Delphi 
public class ButtonBar = class(Bar, IMouseEventProcessor)
JScript 
public class ButtonBar extends Bar implements IMouseEventProcessor 
Managed Extensions for C++ 
public __gc class ButtonBar : public Bar, IMouseEventProcessor  
C++/CLI 
public ref class ButtonBar : public Bar, IMouseEventProcessor  

Example

The example below shows how to create a ButtonBar with three ButtonBarButton components: New, Open and Save. The New ButtonBarButton has a Menu which is displayed when the button is clicked.
C#Copy Code
using System; 
using System.Windows.Forms; 
using ICreate.Controls.Bars; 
using System.Drawing; 
 
namespace ExamplesButtonBarCSharp 

    public partial class ButtonBarClassExample : Form 
    { 
        public ButtonBarClassExample() 
        { 
            InitializeComponent(); 
 
            ButtonBar buttonBar = new ButtonBar(); 
            buttonBar.Dock = DockStyle.Top; 
 
            ButtonBarButton buttonNew = new ButtonBarButton("New", Image.FromFile(@"Resources\new.png")); 
            ButtonBarButton buttonOpen = new ButtonBarButton("Open", Image.FromFile(@"Resources\open.png")); 
            ButtonBarButton buttonSave = new ButtonBarButton("Save", Image.FromFile(@"Resources\save.png")); 
 
            ContextMenuStrip newMenu = new ContextMenuStrip(); 
            newMenu.Items.Add("Document", null, new EventHandler(OnNewDocument)); 
            newMenu.Items.Add("Email", null, new EventHandler(OnNewEmail)); 
            newMenu.Items.Add("Spreadsheet", null, new EventHandler(OnNewSpreadsheet)); 
 
            buttonNew.Menu = newMenu; 
            buttonOpen.Click += new EventHandler(OnOpenClicked); 
            buttonSave.Click += new EventHandler(OnSaveClicked); 
 
            buttonBar.Items.Add(buttonNew); 
            buttonBar.Items.Add(buttonOpen); 
            buttonBar.Items.Add(buttonSave); 
 
            this.Controls.Add(buttonBar); 
        } 
 
        private void OnNewDocument(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewDocument"); 
        } 
 
        private void OnNewEmail(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewDocument"); 
        } 
 
        private void OnNewSpreadsheet(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewSpreadsheet"); 
        } 
 
        void OnOpenClicked(object sender, EventArgs e) 
        { 
            MessageBox.Show("OnOpenClicked"); 
        } 
 
        void OnSaveClicked(object sender, EventArgs e) 
        { 
            MessageBox.Show("OnSaveClicked"); 
        } 
    } 
}
Visual BasicCopy Code
Imports ICreate.Controls.Bars

Public Class ButtonBarClassExample

    Public Sub New()

        InitializeComponent()

        Dim buttonBar As ButtonBar = New ButtonBar
        buttonBar.Dock = DockStyle.Top

        Dim buttonNew As ButtonBarButton = New ButtonBarButton("New", Image.FromFile("Resources\new.png"))
        Dim buttonOpen As ButtonBarButton = New ButtonBarButton("Open", Image.FromFile("Resources\open.png"))
        Dim buttonSave As ButtonBarButton = New ButtonBarButton("Save", Image.FromFile("Resources\save.png"))

        Dim newMenu As ContextMenuStrip = New ContextMenuStrip
        newMenu.Items.Add("Document", Nothing, New EventHandler(AddressOf OnNewDocument))
        newMenu.Items.Add("Email", Nothing, New EventHandler(AddressOf OnNewEmail))
        newMenu.Items.Add("Spreadsheet", Nothing, New EventHandler(AddressOf OnNewSpreadsheet))

        buttonNew.Menu = newMenu
        AddHandler buttonOpen.Click, AddressOf OnOpenClicked
        AddHandler buttonSave.Click, AddressOf OnSaveClicked

        buttonBar.Items.Add(buttonNew)
        buttonBar.Items.Add(buttonOpen)
        buttonBar.Items.Add(buttonSave)
        Me.Controls.Add(buttonBar)

    End Sub

    Private Sub OnNewDocument(ByVal sender As Object, ByVal args As EventArgs)
        MessageBox.Show("OnNewDocument")
    End Sub

    Private Sub OnNewEmail(ByVal sender As Object, ByVal args As EventArgs)
        MessageBox.Show("OnNewDocument")
    End Sub

    Private Sub OnNewSpreadsheet(ByVal sender As Object, ByVal args As EventArgs)
        MessageBox.Show("OnNewSpreadsheet")
    End Sub

    Sub OnOpenClicked(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("OnOpenClicked")
    End Sub

    Sub OnSaveClicked(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("OnSaveClicked")
    End Sub
End Class

Remarks

A ButtonBar is a bar which can contain ButtonBarButton and ButtonBarSeparator components. These components are stored in the ButtonBar Items collection. The ButtonBar can be drawn either vertically or horizontally. The ButtonBarPosition property determines whether the bar is vertical or horizontal. This property also determines the location at which the Menu associated with a ButtonBarButton is shown.

The appearance of the ButtonBar is set using the Style property. The Animate property determines how the appearance of the ButtonBarButton items change  as their state changes. If Animate is true then the colour of the ButtonBarButton components fade from one value to the other as the state changes and the ButtonBarButton Image expands when the mouse cursor is over the ButtonBarButton. The Image contracts when the mouse cursor moves off the ButtonBarButton. If Animate is false then the colour changes are abrupt and the Image size does not change.

The ItemHot event is raised when the mouse cursor moves over a ButtonBarButton. The ButtonBarButton colour changes from ButtonBackColor to HotBackColor. If the ButtonBarButton has a sub button then the ActiveBackColor and HotBackColor properties determine the background color of the button. If the main part of the button contains the mouse cursor then its background colour is HotBackColor and the sub button's background colour is ActiveBackColor. If the sub button contains the mouse cursor then its background colour is HotBackColor and the main button's background colour is ActiveBackColor. Similarly for the colour of the ButtonBarButton Text.

The ItemCold event is raised when the mouse cursor moves off a ButtonBarButton.

The ItemSelected event is raised when a ButtonBarButton is left clicked, or if a ButtonBarButton has input focus and the enter key or space bar pressed. The SubItemSelected event is raised when the sub button of ButtonBarButton is left clicked, or if the sub button has input focus and the enter key or space bar pressed.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.ScrollableControl
               System.Windows.Forms.ContainerControl
                  ICreate.Controls.Bars.Bar
                     ICreate.Controls.Bars.ButtonBar

Requirements

Namespace: ICreate.Controls.Bars

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: ICreate.Controls.Bars (in ICreate.Controls.Bars.dll)

See Also