views:

229

answers:

1

I am trying to create datagridview connected to sqlserver. But it seems that even in simple datagridview cannot handle quickly millions of rows. And so scrolled to upper rows datagridview updates noticably faster, that scrolled down to last row.

The effect can be seen:

    Public Class Form1   
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.
EventArgs) Handles Me.Load
   DataGridView1.VirtualMode = True
   DataGridView1.RowCount = 10000000
   DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
End Sub


Private Sub DataGridView1_CellValueNeeded(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellValueEventArgs) Handles DataGridView1.
CellValueNeeded

e.Value = 1
   End Sub
End Class

''form contains datagridview with 3 columns

Is there some workaround?

A: 

you should set to false any options regarding auto sizing of rows and columns and use a cache for your row data (of size about 2 times the actual number of rows displayed in the grid) see msdn

Jay Cook