0

Hello, guys, I encountered a big problem. There is a genereted matrix of buttons:

private void Single_Load(object sender, EventArgs e)
        {
            //code here
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    //a lot of working code here

                    b[i, j].Click += new System.EventHandler(ClickButton);
                }
            }
        }

What can I do when one of those buttons is pressed (i have the method ClickButton) to know what i and j has he?
I want to make smoething like this

ClickButton()
    {
        if (x%2==0)
            v[i, j] = x; //i and j should be form the matrix of buttons
    }
2
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by BogdanCov
1

You could use the Tag property of a Button, to store the i,j info. Recall it in your ClickButton handler.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.