public static bool DrawGrid(frmGameOfLife form) { bool Result = false; Dictionary <string, int> gridSettings = Grid.GetGridSettings(); form.pnlGrid.Controls.Clear(); int intx = 5, inty = 5; for (var i = 1; i <= gridSettings["columns"]; i++) { string col = alphabets.GetValue(i); if (string.IsNullOrEmpty(col)) { continue; } for (var o = 1; o <= gridSettings["rows"]; o++) { ucGridBox gridBox = new ucGridBox(); gridBox.SetBounds(intx, inty, 50, 50); gridBox.Name = string.Concat(col, o); gridBox.Visible = true; gridBox.Dead = false; gridBox.BackColor = Color.White; gridBox.ForeColor = Color.Black; gridBox.Col = i; gridBox.Row = o; //gridBox.lblKey.Text = gridBox.Name; gridBox.Margin = new Padding(5, 5, 5, 5); gridBox.Show(); form.pnlGrid.Controls.Add(gridBox); intx = gridBox.Bounds.X + 55; } intx = 5; inty += 55; } foreach (ucGridBox cont in form.pnlGrid.Controls) { cont.neightbours = GetCellNeighbours(form, cont); Result = true; } return(Result); }