Best way to fill DataGridView with large amount of data

前端 未结 6 1592
不思量自难忘°
不思量自难忘° 2020-11-30 05:43

I have a windows form that has two DataGridViews (DGVs) that will hold 25,000+ records and 21 columns each. I have successfully loaded each with the data from the DB using

6条回答
  •  [愿得一人]
    2020-11-30 06:20

    this solved my problem:

    array
        ^theRows = nullptr;
    if (DG->Rows->Count == 0)//First Compilation
    {
        int NUMROWS = xxx;
        theRows = gcnew array(NUMROWS);
        for (int nr = 0; nr < DRH->Count; nr++)
            theRows[nr] = gcnew DataGridViewRow();
    //Do not remove the two following
        DG->Rows->AddRange(theRows);
        DG->Rows->Clear();
    }
    else //Update
    {
    
        theRows = gcnew array(DG->Rows->Count);
        DG->Rows->CopyTo(theRows, 0);
        DG->Rows->Clear();
    
    }
    for(int nr=0;nrLength;nr++)
    {
        theRows [nr]->SetValues("val1", "val2");
    }
    DG->Rows->AddRange(theRows);
    

提交回复
热议问题