dataGridView1.RowCount = 36;
dataGridView1.ColumnCount = 30;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dataGridView1.Font = new Font(dataGridView1.Font, FontStyle.Bold);
if (e.KeyCode == Keys.Space)
{
char ch = Convert.ToChar(dataGridView1.Rows[currentRow].Cells[currentCol].Value);
if(ch == defaultChar)
dataGridView1.Rows[currentRow].Cells[currentCol].Style.BackColor = Color.Yellow;
else dataGridView1.Rows[currentRow].Cells[currentCol].Style.BackColor = Color.Coral;
}
var watch = System.Diagnostics.Stopwatch.StartNew();
// your code
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);
var cell = dataGridView1.Rows[currentRow].Cells[currentCol];
Find more questions by tags C#ProgrammingWindows Forms