c# - Navigating through a grid of panels -


i'm trying make little project in c# using small grid of panels , 4 direction buttons shown here:

enter image description here

but don't know how create easy navigation system using panels. "character" colored panel. panels named coordinates in front of them (p11 p66) there way kind of function take position of "character" , color panel on same position?

example

int coords = 21;  private void up_click(object sender, eventargs e) {     move(10); }  void move(int coordchange) {     pcoords.backcolor = color.white;     coords = coords + coordchange     pcoords.backcolor = color.black; } 

the pcoords part supposed panel on. part don't know how make.

public class panels {      public panel[, ] panelsarray=new panel[6,6] ;      int xcoordinate;      int ycoordinate;      public panel currentpanel{get{return panelsarray[xcoordinate,ycoordinate];}      public void moveup()      {          beforemove();          if(ycoordinate>0) ycoordinate--;          onmove();      }      //declare movedown, moveleft , moveright similiarly      ...      private void beforemove()      {          currentpanel.backcolor=color.white;      }      private void onmove()      {         currentpanel.backcolor=color.black;      } } 

then in form class

public partial class form1 : form {     public panels panels=new panels();     public form1()     {             initializecomponent();             panels.panelsarray[0,0]=p00;             panelspanelsarray[1,0]=p10;             panels.panelsarray[2,0]=p20;             //...             panels.panelsarray[5,5]=p55;      } ... 

you want add in code set starting colours , coordinates.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -