samedi 28 mars 2015

Getting the index of a 2D array from sender


I am making a Minesweeper game in C++ for a class assignment and am using a 2-Dimensional array of buttons. My question is how would I get the index of the array (ex: if buttons[1,2] is clicked ... y is set to 1 and x is set to 2.



cli::array<Button^, 2>^ buttons; //make array global
buttons = gcnew cli::array<Button^, 2>(10, 10); // initialize buttons

//code below in for loop to go through all 100 buttons
buttons[y, x]->Click += gcnew EventHandler(this, &Form1::buttons_Click);

void buttons_Click(Object ^sender, EventArgs ^args) {
//if buttons[sendery][senderx] ...
}



Aucun commentaire:

Enregistrer un commentaire