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
    }

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

thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.