I recently developed an app that has a datagridview
on it. After a couple minutes of testing i noticed that the performance is very bad and there are issues while rendering data(lag,slow manipulation) i was also searching for solutions like enabling virtual mode and so on ... to no avail, can you please suggest or help me is there a way i can enhance the performance and mode this code.
So here is my code:
private void LoadTable()
{
var connection = Connection.prevzemiKonekcija();
var adapter1 = new MySqlDataAdapter();
var sqlSelectAll = "SELECT * from prodavnica.artikli";
adapter1.SelectCommand = new MySqlCommand(sqlSelectAll, connection);
var table = new DataTable();
adapter1.Fill(table);
var bajndsors = new BindingSource();
bajndsors.DataSource = table;
dataGridView1.DataSource = bajndsors;
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Linen;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor =
Color.Cornsilk;
/*
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dataGridView1.AutoResizeColumns();
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Red;
dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow;
*/
dataGridView1.Columns[0].HeaderText = "РЕД.БР";
dataGridView1.Columns[1].HeaderText = "ШИФРА";
dataGridView1.Columns[2].HeaderText = "НАЗИВ";
dataGridView1.Columns[3].HeaderText = "НАБАВНА ЦЕНА";
dataGridView1.Columns[4].HeaderText = "ПРОДАЖНА ЦЕНА";
dataGridView1.Columns[5].HeaderText = "КОЛИЧИНА";
dataGridView1.Columns[6].HeaderText = "ДАНОК";
dataGridView1.Columns[7].HeaderText = "ОПИС";
dataGridView1.Columns[8].HeaderText = "ДОЛГ ОПИС";
dataGridView1.Columns[9].Visible = false;
dataGridView1.Columns[10].HeaderText = "ЕДИНИЦА";
dataGridView1.Columns[11].HeaderText = "ПРОФИТ";
dataGridView1.Columns[12].HeaderText = "ПРОИЗВОДОТЕЛ";
this.dataGridView1.VirtualMode = true;
//dataGridView1.Columns["MakArtikal"].Visible = false;
connection.Close();
}