I have a 2D button array (buttons) that will generate a 5 by 5 grid of buttons. I want to get the index of a single button (say, (2,2) in the center) when clicked, and find the index values of buttons surrounding the original button within a 3 x 3 radius by creating integer variables such as topcentre (which would be the index of buttons(x, y - 1) or 1,2, where x and y are the values of the clicked button.) I can then add text, etc. to those surrounding buttons.
Here's a visualization:
0,0|0,1|0,2|0,3|0,4
1,0|1,1|1,2|1,3|1,4
2,0|2,1|2,2|2,3|2,4
3,0|3,1|3,2|3,3|3,4
4,0|4,1|4,2|4,3|4,4
How can I do this?