Forms - Button Click

This is a discussion on Forms - Button Click within the C# Programming forums, part of the General Programming Boards category; I have an array of buttons and a method suits for all buttons. But, how can I know which button ...

  1. #1
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265

    Forms - Button Click

    I have an array of buttons and a method suits for all buttons. But, how can I know which button in the array was clicked? ([0,0] \ [0,1] ...)
    Can I pass information to the method?

    Thanks.
    gavra.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    The Click event passes the sender (button):
    Code:
    void Button1_Click(object Sender, System.EventArgs EventArgument)
    {
      var Button = Sender as System.Windows.Forms.Button;
      //Store extra data in Button.Tag if neccessary
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a function pointer from a button click event?
    By dxfoo in forum Windows Programming
    Replies: 20
    Last Post: 01-29-2008, 02:35 AM
  2. Button click out of WM_COMMAND
    By Sober in forum Windows Programming
    Replies: 8
    Last Post: 05-03-2007, 09:07 PM
  3. Updating window after button click?
    By ac251404 in forum Windows Programming
    Replies: 0
    Last Post: 07-18-2006, 10:20 AM
  4. Click button on dialog box to open window.
    By ooosawaddee3 in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2002, 07:53 AM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21