none
Load Datagridview with large amount of data progressively

    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!
    Friday, September 17, 2010 5:31 AM

Answers

All replies

  • This thread may provide a solution that can help:

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/cb6da743-0314-4dde-8a79-649b3fa4ea60

    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)


    Success
    Cor
    • 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