There is a WinForms project, it is a dataGridView in the form designer, the following code:
dataGridView1.RowCount = 36;
dataGridView1.ColumnCount = 30;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dataGridView1.Font = new Font(dataGridView1.Font, FontStyle.Bold);
The property grid Dock = Fill.
Like rows and columns of anything, but with a smooth change of the size of the form begin terrible brakes.
Also in the KeyDown event handler is some code that when you press the space bar paint in a different color of a grid cell depending on its content:
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;
And then also, when painting the cell there is a short, but noticeable and critical for my tasks hang for about 0.5 seconds(you want to immediately use the keypad to move to the next cell). If you make the table size 10x15, then the lag is almost there, it is barely noticeable, but still. The application runs on a machine with i7-4790 3.6 GHz.
Why dataGridView is so slow and is there a way to fix it?