This is a migrated thread and some comments may be shown as answers.

RadGridView initialization delay

1 Answer 242 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 12 Jun 2012, 07:08 AM
Hi,
Could I make RadGridView control's initialization faster? Currently first initialization of this control can take few seconds, what is quite long in case of dialog window, appearing on demand.

Sample code:

public partial class RadGridViewDialog : Form
{
    private RadGridView _grid;
  
    public RadGridViewDialog()
    {
        InitializeComponent();
    }
  
    private void btnInitialize_Click(object sender, EventArgs e)
    {
        _grid = new RadGridView();
          
        panel2.Controls.Add(_grid);
        _grid.Dock = DockStyle.Fill;
        _grid.BringToFront();
    }
  
    private void btnBuild_Click(object sender, EventArgs e)
    {
        using (_grid.DeferRefresh())
        {
            GridViewDataColumn firstColumn = new GridViewTextBoxColumn();
            firstColumn.HeaderText = "Name";
            _grid.Columns.Add(firstColumn);
            firstColumn.ReadOnly = true;
  
            GridViewDataRowInfo[] rows = new GridViewDataRowInfo[200];
  
            GridViewDataColumn secondColumn = new GridViewTextBoxColumn();
            secondColumn.HeaderText = "Value";
            _grid.Columns.Add(secondColumn);
            secondColumn.Width = 110;
            secondColumn.MinWidth = 70;
  
  
            int rowIndex = 0;
            for (int i = 0; i < rows.Length; i++)
            {
                rows[rowIndex] = new GridViewDataRowInfo(_grid.MasterView);
                rows[rowIndex].Cells[0].Value = "name" + i;
                rows[rowIndex].Cells[1].Value = "value" + i;
                rowIndex++;
            }
            firstColumn.IsPinned = true;
            _grid.Rows.AddRange(rows);
            firstColumn.BestFit();
        }
    }
}


After first opening this form, when user clicks on btnInitialize button application is freezing for few seconds, clicking on btnBuild button is much faster. Second and next clicks on btnInitialize (no matter in the same or other dialog in the same application) are faster too.

I've noticed that it's a reason of calling:
Telerik.WinControls.Themes.ControlDefault.ExternalControlsThemeHelper.LoadGridThemes()
in the static constructor of class Telerik.WinControls.UI.RadGridViewElement.

Is it possible to speed up first initialization of this class?

Regards

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Jun 2012, 08:02 AM
Hi Raymond,

Thank you for writing.

When loading a control from our suite for first time the themes are loaded too and this causes the observed delay. Unlike the default WinForms controls our suite offers animations and themes and loading them takes its time. This time increases when using a lot of controls like in your application. Once the themes are loaded the startup time is improves, as you noticed in subsequent loading of the grid.

The following KB articles summarize ways to optimize an application with our controls:

Another thing that you can do is to initialize the grid in the RadGridViewDialog's constructor, so the initial loading time will be moved to the form opening and then when you press the Initialize button it will add the grid faster.

I hope that the provided information addresses your questions. Let us know if you have any additional inquiries. 
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Raymond
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or