Results 1 to 2 of 2

Thread: using a toolbar in c#

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275

    using a toolbar in c#

    Hey..i just made a toolbar..how do i detect when each button is pressed?

  2. #2
    Member
    Join Date
    Mar 2003
    Posts
    34
    When one of the toolbar button's is clicked, the buttonclick event is raised. Via the ToolBarButtonClickEventArgs parameter, you are able to interogate the button property to determine which button was selected. Here is one way that determines the button in question using the equals() method. This method checks the equality by comparing object references:

    Code:
    private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) {
        if (e.Button.Equals(this.btnAdd)) {
            MessageBox.Show("Add Clicked");
        }else {
            MessageBox.Show("Remove Clicked");
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width