Answer the question
In order to leave comments, you need to log in
Why slows down dataGridView?
There is a WinForms project with a dataGridView and the following code in the form constructor:
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.GreenYellow;
else dataGridView1.Rows[currentRow].Cells[currentCol].Style.BackColor = Color.Coral;
}
Answer the question
In order to leave comments, you need to log in
DataGridView в принципе тормозит при большом количестве данных (гугл подтвердит). Можно сделать пейждинг или...кастомный грид.
На какой строчке кода тормозит? Замерьте.
var watch = System.Diagnostics.Stopwatch.StartNew();
// ваш код
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);
var cell = dataGridView1.Rows[currentRow].Cells[currentCol];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question