public void CreateMineField() { //clear everything that was there mineField.Controls.Clear(); mineField.RowStyles.Clear(); mineField.ColumnStyles.Clear(); //create width mineField.ColumnCount = width; for (int i = 0; i < width; i++) { mineField.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); } //create height mineField.RowCount = height; for (int i = 0; i < height; i++) { mineField.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } board.DrawBoard(mineField); }