da ra

da ra

  • NA
  • 1
  • 2.2k

DataGridView, Virtual Mode and lagging

Nov 24 2011 7:42 AM
My code looks as follows:


private void dataGridView4_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            Records recordsTmp  = null;
            recordsTmp = (Records)this.ArrayOfRecords[e.RowIndex]; //ArrayList with string[] objects inside


            switch (dataGridView4.Columns[e.ColumnIndex].HeaderText)
            {
                case "#":
                    e.Value = recordsTmp .nr;
                    break;
                case "ip":
                    e.Value = recordsTmp .Ip;
                    break;
                case "long":
                    e.Value = recordsTmp .Long;
                    break;
                case "3":
                    e.Value = recordsTmp .type;
                    break;
                case "4":
                    e.Value = customerTmp.time;
                    break;
            }

dataGridview is updating dynamically like 10 new records per 1 secs. theres another piece of code thats adding new records(string []) to the ArrayOfRecords
So theres no problem with 2000 records. But with 8000 when im trying to select a row it needs like 4 secs to do it. The time is decreasing as im selecting lower rows. Like 1000 - 0,5 s to select/4000 - 2 secs etc. Why it takes so much time? And the 2nd thing why it raises CellValueNeededevent when im moving my mouse over the rows?(its a waste of resources) ?