I am trying to create a game that has a grid and the user can click the grid areas to toggle their state. I am using WinForms. I can find 2 ways to do this, both seem complicated:
- A table-layout-panel, and place a label or button in each area, and when the button is clicked, figure out (somehow) which column and row the click was in and act accordingly.
- An unbound GridView.
Both seem very complicated to handle something like this.
For example, think of a tic-tac-toe game. All I want in this case is a 3×3 grid, and to know which area (x,y) was clicked and draw something in this area.
Let me show you something i have written that come closer to your needs, maybe:
Before Click:
After Click:
Note that i’ve create columns and rows by designer, but i think it’s nothing special to create them programmatically.
What could be the next steps?
Hope this helps a little bit.