RadGridView vs DataGridView Performance

6 posts, 0 answers
  1. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 06 Aug 2019 Link to this post

    Hi Admins

    Previously i was using Default DataGridView for populating a Table.

    It was working fine. But due to advace Functionality of RadGridView, I have develop the same with Telerik Controls (R2 SP1 2019).

    But i have some Performance Issues.

    Check the Sample Code and please suggest me for Performance Enhancement.

    I'm Creating Column at Run Time Using This Code and Setting Grid Properties.

    this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.ShowGroupPanel = false;
    this.radGridView1.MasterTemplate.EnableGrouping = false;
    this.radGridView1.EnableHotTracking = true;
    this.radGridView1.MasterTemplate.SelectionMode = GridViewSelectionMode.FullRowSelect;
    this.radGridView1.AllowAddNewRow = false;
    this.radGridView1.AllowEditRow = false;
     
    GridViewTextBoxColumn ColumnId = new GridViewTextBoxColumn
    {
             Name = "suppid",
             HeaderText = "Code",
             FieldName = "suppid",
             Width = 80,
             HeaderTextAlignment = ContentAlignment.MiddleCenter,
             TextAlignment = ContentAlignment.MiddleCenter
         };
    radGridView1.MasterTemplate.Columns.Add(ColumnId);

     

    I'm creating 10 different Columns using the Above Code.

    Using the Below Code loading the Data to GridView

    DataTable dt = new DataTable();
    string query = "Select suppid from p_supplier" ;
    SqlCommand cmd = new SqlCommand(query, Conn);
    SqlDataAdapter DA = new SqlDataAdapter(query, Conn);
    DA.Fill(dt);
     
    BindingSource source = new BindingSource();
    source.DataSource = dt;
    radGridView1.MasterTemplate.DataSource = source;

     

    I have shown you only 1 Column only to shorten my Code.

    Please Suggest.

  2. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 06 Aug 2019 Link to this post

    Is it any Performance issue to create columns and Setting of RadGridView at Run-time instead of Design-Time
  3. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3575 posts

    Posted 09 Aug 2019 Link to this post

    Hello, Muhammad, 

    According to the provided code snippet, it seems that you populate the columns in RadGridView programmatically. I suppose that the AutoGenerateColumns property is set to false. Thus, when you set the RadGridView.DataSource, the already added columns will be used. Everything seems to be pretty straight-forward. That is why it is difficult to determine what causes the performance problems that you mentioned. 

    Could you please specify how many rows you load in RadGridView?

    If you have a large number of rows in the grid, it would be good to consider using RadVirtualGrid. It is a grid component developed on top of Telerik Presentation Framework which provides a convenient way to implement your own data management operations and optimizes the performance when interacting with large amounts of data: https://docs.telerik.com/devtools/winforms/controls/virtualgrid/overview

    However, if you insist on using RadGridView, I would kindly ask you to submit a support ticket and provide additional information how to replicate the undesired behavior that you are facing. A sample project would be very useful for further investigating the case. Thus, our support staff will gladly assist you.

    Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

    Thank you for your understanding.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 10 Aug 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks for your kind reply.

    Yes i populating the data programmatically with AutoGenrateColumns=False.

    Right now the grid only populate 300 Rows.

    I will try to use VirtualGrid.

    Can you Guide me How can i Populate the Grid only after Form is Fully displayed on screes.

  5. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 10 Aug 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    radVirtualGrid1.BeginUpdate();
     
    radVirtualGrid1.EndUpdate();

     

    Required Little Explanation for this Code of lines.

    These are used at Many places in the Demo provided.

    Does this help to overcome performance Issues.

     

    Thanks

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3575 posts

    Posted 12 Aug 2019 Link to this post

    Hello, Muhammad,     

    Indeed, using RadGridView.BeginUpdate and RadGridView.EndUpdate methods are the suitable approach for improving performance when adding multiple rows programmatically. Note that when you add a row, this will refresh the grid. Hence, if you add 300 rows, 300 refresh operations will be performed. But it is not necessary. You need to refresh just once after the last row is added. That is why call the RadGridView.BeginUpdate method before adding the rows and the RadGridView.EndUpdate method after adding the rows which will suspend the layout while you are adding rows and only at the end the grid will be refreshed.

    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top