I am making a chess game and I am using array of buttons dynamically so, I am using a single click event for all of them. I want to ask user for inputs on button's click event(where the user wants to put the piece once the button is clicked). How can I do that as I am new to C# and have tried a lot but couldn't figure it out.
Here's my code:
private void Btn_Click(object sender, EventArgs e)
{
//for black pieces
Button btn2 = new Button();
btn2 = sender as Button;
int k;
int l;
for (int i=0; i<8; i++)
{
for(int j=0; j<8; j++)
{
if (btn2.BackgroundImage == blackpawn)
{
if (btn2 == btn[i, j])
{
//here i want to ask user where he wants to put the piece
btn[i, j].BackgroundImage = null;
k = ++i;
l = j;
btn[k, l].BackgroundImage = blackpawn;
btn[k, l].BackgroundImageLayout = ImageLayout.Stretch;
}
}
}
}
}