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

Page View is SUPER slow

4 Answers 295 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Chris Kirkman
Top achievements
Rank 1
Chris Kirkman asked on 19 Nov 2010, 09:45 PM
I have a page view in my application.  Programmatically, I add 3 pages.  On each page I add a TableLayoutPanel.  Inside each panel I add about 15 rows with 2 columns each.  Each column has one label and one "other" control.  The "other" control is one of the following...

RadTextBox
RadCheckBox
RadDropDownList
RadSpinEditor

The pages with the drop down and spin editor takes several seconds to load and my processor is pegged!

I'm not hitting the database at this time, it is definitely in the control.

4 Answers, 1 is accepted

Sort by
0
Chris Kirkman
Top achievements
Rank 1
answered on 19 Nov 2010, 10:45 PM
One thing I've discovered.  If I remove RadControl.Dock = DockStyle.Fill and just leave it alone, the UI loads quick.  It seems to potentially be an issue with the TableLayoutPanel.

??
0
Emanuel Varga
Top achievements
Rank 1
answered on 20 Nov 2010, 03:00 AM
Hello Chris,

There is one thing you could do to speed up initial load, and that is to create and load the controls just when the page handle is being created, this event will only fire once and it is intended for lazy loading of pages.

An example would be the following (here you can test both with lazy loading and without)
using System;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    private RadPageView radPageView1;
    private int noRows = 10;
    private int noColumns = 2;
 
    public Form1()
    {
        InitializeComponent();
        this.Size = new Size(800, 600);
        this.Controls.Add(radPageView1 = new RadPageView());
        radPageView1.SelectedPageChanging += new EventHandler<RadPageViewCancelEventArgs>(radPageView1_SelectedPageChanging);
        radPageView1.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
        radPageView1.Dock = DockStyle.Fill;
    }
 
    protected override void OnLoad(EventArgs e)
    {
        this.Cursor = Cursors.WaitCursor;
        base.OnLoad(e);
 
        for (int i = 0; i < 10; i++)
        {
            CreatePageWithLazyLoading(i);
            //CreatePage(i);
        }
    }
 
    void radPageView1_SelectedPageChanged(object sender, EventArgs e)
    {
        this.Cursor = Cursors.Default;
    }
 
    void radPageView1_SelectedPageChanging(object sender, RadPageViewCancelEventArgs e)
    {
        this.Cursor = Cursors.WaitCursor;
    }
 
    private void CreatePageWithLazyLoading(int pageNo)
    {
        var page = new RadPageViewPage();
        page.Text = "Page" + pageNo;
        page.HandleCreated += new EventHandler(page_HandleCreated);
        radPageView1.Pages.Add(page);
    }
 
    private void CreatePage(int pageNo)
    {
        var page = new RadPageViewPage();
        page.Text = "Page" + pageNo;
 
        //here you can do some other checks, page text, page tag and so on
        //after this let's load the controls.
        CreateTableLayoutForPageWithControls(page);
        radPageView1.Pages.Add(page);
    }
 
    void page_HandleCreated(object sender, EventArgs e)
    {
        var page = sender as RadPageViewPage;
        if (page == null)
        {
            return;
        }
 
        //here you can do some other checks, page text, page tag and so on
        //after this let's load the controls.
        CreateTableLayoutForPageWithControls(page);
    }
 
    private void CreateTableLayoutForPageWithControls(RadPageViewPage page)
    {
        var tableLayout = new TableLayoutPanel();
        tableLayout.Dock = DockStyle.Fill;
 
        for (int i = 0; i < noRows; i++)
        {
            tableLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / noRows));
            tableLayout.RowCount++;
            for (int j = 0; j < noColumns; j++)
            {
                if (tableLayout.ColumnCount - 1 < j)
                {
                    tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / noColumns));
                    tableLayout.ColumnCount++;
                }
 
                var control = GetControlForRowIndex(i);
                control.Text = "Row " + i + ", Column " + j;
                control.Dock = DockStyle.Fill;
                tableLayout.Controls.Add(control);
            }
        }
 
        page.Controls.Add(tableLayout);
    }
 
    private RadControl GetControlForRowIndex(int i)
    {
        if (i % 4 == 0)
        {
            return new RadTextBox();
        }
        else if (i % 3 == 0)
        {
            return new RadDropDownList();
        }
        else if (i % 2 == 0)
        {
            return new RadCheckBox();
        }
        else
        {
            return new RadSpinEditor();
        }
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Stefan
Telerik team
answered on 25 Nov 2010, 08:53 AM
Hi Chris, 

Thank you for reporting this. 

I have looked into your case and indeed we experience an issue in this scenario. Currently, I can not provide you with a work around. We will address this case in a future release. You can find its PITS item
here.

Your Telerik points have been updated for this report. 
 
Best wishes,
Stefan
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Sebastian
Top achievements
Rank 1
answered on 07 Dec 2011, 10:12 PM
I had the same issue and I found other workaround. In my case I had TableLayoutPanel with RadSplittButton in each cell and each RadSplitButon was set as Dock = Fill. If I set AutoSize = false for RadSplitButton then the performance was ok and everything looks ok too.
Tags
PageView
Asked by
Chris Kirkman
Top achievements
Rank 1
Answers by
Chris Kirkman
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Stefan
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or