ICreate.Controls.Bars Send comments on this topic.
SubButtonClick Event
See Also  Example
ICreate.Controls.Bars Namespace > ButtonBarButton Class : SubButtonClick Event






Occurs when a subordinate button of a ButtonBarButton is clicked.

Syntax

Visual Basic (Declaration) 
Public Event SubButtonClick() As EventHandler
Visual Basic (Usage)Copy Code
Dim instance As ButtonBarButton
Dim handler As EventHandler
 
AddHandler instance.SubButtonClick, handler
C# 
public event EventHandler SubButtonClick()
Delphi 
public event SubButtonClick: EventHandler; 
JScript 
In JScript, you can handle the events defined by another class, but you cannot define your own.
Managed Extensions for C++ 
public: __event EventHandler* SubButtonClick();
C++/CLI 
public:
event EventHandler^ SubButtonClick();

Example

The example below shows how to implement a SubButtonClick event handler. The example creates a ButtonBar with a New ButtonBarButton. The New button has a sub button. A menu is displayed when the sub button is clicked. Instead of manually displaying the menu you can assign a menu to the Menu property in which case the menu is automatically shown when the sub button is clicked.
C#Copy Code
using System; 
using System.Windows.Forms; 
using ICreate.Controls.Bars; 
 
namespace ExamplesButtonBarButtonCSharp 

    public partial class SubButtonClickExample : Form 
    { 
        public SubButtonClickExample() 
        { 
            InitializeComponent(); 
 
            ButtonBar buttonBar = new ButtonBar(); 
            ButtonBarButton newButton = new ButtonBarButton("New", null); 
            buttonBar.Items.Add(newButton); 
            Controls.Add(buttonBar); 
 
            newButton.SubButton = true; 
            newButton.SubButtonClick += new EventHandler(OnNewSubButtonClicked); 
            newButton.Click += new EventHandler(OnNewClicked); 
        } 
 
        private void OnNewSubButtonClicked(object sender, EventArgs e) 
        { 
            ContextMenuStrip menu = new ContextMenuStrip(); 
            menu.Items.Add("New document", null, new EventHandler(OnNewDocument)); 
            menu.Items.Add("New email", null, new EventHandler(OnNewEmail)); 
            menu.Items.Add("New fax", null, new EventHandler(OnNewFax)); 
            menu.Show(Cursor.Position); 
        } 
 
        void OnNewClicked(object sender, EventArgs e) 
        { 
            MessageBox.Show("OnNewClicked"); 
        } 
 
        private void OnNewDocument(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewDocument"); 
        } 
 
        private void OnNewEmail(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewEmail"); 
        } 
 
        private void OnNewFax(object sender, EventArgs args) 
        { 
            MessageBox.Show("OnNewFax"); 
        } 
    } 
}
Visual BasicCopy Code
Imports ICreate.Controls.Bars

Public Class SubButtonClickExample

    Public Sub New()
        InitializeComponent()

        Dim buttonBar As ButtonBar = New ButtonBar
        Dim newButton As ButtonBarButton = New ButtonBarButton("New", Nothing)
        buttonBar.Items.Add(newButton)
        Controls.Add(buttonBar)

        newButton.SubButton = True
        AddHandler newButton.SubButtonClick, AddressOf OnNewSubButtonClicked
        AddHandler newButton.Click, AddressOf OnNewClicked

    End Sub

    Private Sub OnNewSubButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
        Dim menu As ContextMenuStrip = New ContextMenuStrip
        menu.Items.Add("New document", Nothing, AddressOf OnNewDocument)
        menu.Items.Add("New email", Nothing, AddressOf OnNewEmail)
        menu.Items.Add("New fax", Nothing, AddressOf OnNewFax)
        menu.Show(Windows.Forms.Cursor.Position)
    End Sub

    Private Sub OnNewClicked(ByVal sender As Object, ByVal args As EventArgs)
        MessageBox.Show("OnNewClicked")
    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("OnNewEmail")
    End Sub

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

End Class

Remarks

This event is raised when the subordinate button of a ButtonBarButton is clicked or when the sub button has input focus and the enter key or space bar is pressed. Note that the SubItemSelected event is also raised when the sub button is clicked.

Requirements

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

See Also