Load Datagridview with large amount of data progressively RRS feed

  • Question

  • Hello,

    I ve a windowappliaction in which onloading form using Gridview to dispaly data.

    I am able to load smallamount of data in gridview with minor delay in load.

    I want to load Gridview progressively, so there ll be no delay in loading.

    How can i do this?

    On loading i am fetching datatable from SQL, which has the thousands of row. and i ve to bind that in datagridview ....

    Thanks for the help!
    • Moved by CoolDadTx Tuesday, August 6, 2019 5:45 PM Winforms related
    Friday, September 17, 2010 5:31 AM


All replies

  • This thread may provide a solution that can help:


    Hope this helps.

    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by Bin-ze Zhao Monday, September 27, 2010 6:53 AM
    Friday, September 17, 2010 6:19 AM
  • You can use datagrid virtual mode.

    All you need - it's set dataGridView VirtualMode property to "true".

    Show data after this enabled with DataGridView

    event CellValueNeeded.

    This event appeared when data must be showed.

    But this methode is not just simple as binding.

    You must work with columns names, have a lot of each, or do like in this sample

     List<TestObject> values;
        private void dataGridView1_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
          TestObject value = values[e.RowIndex];
          string fieldName = dataGridView1.Columns[e.ColumnIndex].Name;
          e.Value = value.GetType().GetField(fieldName).GetValue(value);

    Virtual mode is good only for show static data.

    So you don't have avtomatic Datagrid sort mode, if need - you must do it yourself (sorting your collection by specific field).

    Also if you want DataGridView to be able to change values you must use events - cellValuePushed or cellValueChanged.

    So, virtual mode is not very simple but often, if i have big volume of data - I use it

    Friday, September 17, 2010 6:21 AM
  • Use Threading....
    Friday, September 17, 2010 6:23 AM
  • You simply should not load a datagridview with a large amount of data.

    It does not only load very slow, but it is impossible to use by the users.

    The only result you get is that your users ask you to change it in a way they can use it.

    (For instance using a where clause in your SQL select statement)

    • Marked as answer by Jiten Patoliya Monday, October 25, 2010 12:21 PM
    Friday, September 17, 2010 7:11 AM
  • Hi,

    Here is a new idea I have come across. I am not using virtual method but this is a more efficient way of loading data when 1000s of record has to be laded in background while showing the first 10 or 20 records very fast.

    See my blog link http://anilalsambasivan.blogspot.com/2011/03/post-2-how-to-speedup-heavy-data.html

    Anilal Sambasivan

    Thursday, April 7, 2011 11:45 AM
  • Hello,

    If you have a huge amount of rows, like 10 000 and more,

    to avoid performance leak - do the following before data binding:

    dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing; //or even better .DisableResizing. Most time consumption enum is DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders
    dataGridView1.RowHeadersVisible = false; // set it to false if not needed

    after data binding you may enable it.

    Assembler (.../z80/x86/x64...) the best language I've ever known

    Wednesday, June 12, 2013 3:19 PM
  • The answer to your problem is as simple as , 

    enabling virtual mode and disabling both scrolling bars .

    I was able to reload real time 73.645 rows :)

    (if for some reason stop responding , please use timer to reload every 30 sec or smth)

    • Edited by NEETShonen Tuesday, August 6, 2019 4:58 PM
    Tuesday, August 6, 2019 4:58 PM