Funny thing I came across this question today as I am currently working on an A* variation Grid-Search to teach my students next week... Just for testing purposes I made a WinForm with a FlowLayoutPanel control that was 400 x 400 and divided it into and 8x8 Grid resulting in a 50x50 Cell.
I then wrote the following code to populate the panel.
protected List<string> Colors;
protected Color RandomColor()
{
Color ret;
return ret;
}
private void Form1_Load(object sender, EventArgs e)
{
Colors = new List<string>();
Grid8x8.Margin = new System.Windows.Forms.Padding(0);
Grid8x8.Padding = new System.Windows.Forms.Padding(0);
Grid8x8.BorderStyle = BorderStyle.FixedSingle;
Initialize();
}
private void Initialize()
{
Colors.Clear();
Grid8x8.Controls.Clear();
int i;
for (i = 0; i < 64; i++)
{
cell = new Label();
cell.Text = i.ToString();
cell.AutoSize = false;
cell.BorderStyle = BorderStyle.None;
cell.TextAlign = ContentAlignment.MiddleCenter;
cell.Width = 50;
cell.Height = 50;
cell.Margin = new System.Windows.Forms.Padding(0);
currentColor = RandomColor();
previousColor = currentColor;
cell.BackColor = currentColor;
Grid8x8.Controls.Add(cell);
Colors.Add(currentColor.ToString());
}
}
Since the List is 0-based index instead of a multi-dimensional array its safe to say that if X == CurrentCellIndex then X + 8 will equal the Cell Directly below the CurrentCellIndex.
Hope this helps,
-ArtificerGM