Page View is SUPER slow

5 posts, 0 answers
  1. Chris Kirkman
    Chris Kirkman avatar
    37 posts
    Member since:
    Jul 2012

    Posted 19 Nov 2010 Link to this post

    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.

  2. Chris Kirkman
    Chris Kirkman avatar
    37 posts
    Member since:
    Jul 2012

    Posted 19 Nov 2010 Link to this post

    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.

    ??

  3. DevCraft Release
  4. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2010 Link to this post

    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

  5. Stefan
    Admin
    Stefan avatar
    2452 posts
    Member since:
    Sep 2012

    Posted 25 Nov 2010 Link to this post

    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.

  6. Sebastian
    Sebastian avatar
    1 posts
    Member since:
    Sep 2011

    Posted 07 Dec 2011 Link to this post

    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.

Back to Top
DevCraft Release