RadPageView Auto Size Problem, ExplorerBar Mode – PageViewPage AutoSizeToBestFit

2 posts, 0 answers
  1. Darryl
    Darryl avatar
    1 posts
    Member since:
    Jun 2012

    Posted 12 Feb 2013 Link to this post

    Hello,

     

    I would like the RadPageViewPage to automatically resize itself to its contents when the contents is changed.

     

    It appears that when the contents of the RadPageViewPage is changed its height stays the same. fig1 shows the height before content is modified fig2 shows the height after content is modified(pressing ‘Next’ button), fig3 shows the height after one of the RadPageViewPage tabs is clicked, clicking 'Next' after that keeps the same height. It appears that if a tab is clicked the RadPageView resizes itself. So how can I make the RadPageView resize itself to its content programmatically.

     

    Code to reproduce:

     

        public Form1()
        {
            InitializeComponent();
     
            var spa = new SplitContainer()
            {
                Orientation = Orientation.Horizontal,
                Dock = DockStyle.Fill
            };
            spa.FixedPanel = FixedPanel.Panel2;
            spa.SplitterDistance =300;
            this.Controls.Add(spa);
     
            var rpv = new RadPageView()
            {
                Dock = DockStyle.Fill,
                ViewMode = PageViewMode.ExplorerBar
            };
            ((RadPageViewExplorerBarElement)rpv.GetChildAt(0)).ContentSizeMode = ExplorerBarContentSizeMode.AutoSizeToBestFit;
            var pag = Enumerable.Range(0, 3).Select(a =>
                new RadPageViewPage() { Name = "Page" + a, Text = "Page" + a, IsContentVisible = true }
            );
            rpv.Controls.AddRange(pag.ToArray());
     
            spa.Panel1.Controls.Add(rpv);
     
            var cn = 0;
            var b1 = new Button() { Text = "Next" };
            b1.Click += (o, e) =>
            {
                var cpag = rpv.Controls.Cast<RadPageViewPage>().ToList();
                cpag.ForEach(a => a.Controls.Clear());
                cpag.ForEach(a => a.Controls.Add(new RadLabel() { Text = (cn++) + "\na\nb\nc\nd\ne\n" }));
            };
            spa.Panel2.Controls.Add(b1);
        }
    }

     

    Any help would be appreciated,

  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 15 Feb 2013 Link to this post

    Hi Darryl,

    Thank you for writing.

    I successfully reproduced the issue using your code snippet. The issue is logged to our
    Public Issue Tracking System. The fix will be available in one of the next releases after the upcoming Q1 2013. Currently, as a workaround you can increase and decrease the Width of RadPageView to force the layout.
    using System.Linq;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    namespace Lab.Page
    {
        public partial class PageViewSizeForm : Form
        {
            public PageViewSizeForm()
            {
                InitializeComponent();
     
                var spa = new System.Windows.Forms.SplitContainer()
                {
                    Orientation = Orientation.Horizontal,
                    Dock = DockStyle.Fill
                };
     
                spa.FixedPanel = FixedPanel.Panel2;
                spa.SplitterDistance = 300;
                this.Controls.Add(spa);
     
                var rpv = new RadPageView()
                {
                    Dock = DockStyle.Fill,
                    ViewMode = PageViewMode.ExplorerBar
                };
                ((RadPageViewExplorerBarElement)rpv.GetChildAt(0)).ContentSizeMode = ExplorerBarContentSizeMode.AutoSizeToBestFit;
                var pag = Enumerable.Range(0, 3).Select(a =>
                    new RadPageViewPage() { Name = "Page" + a, Text = "Page" + a, IsContentVisible = true }
                );
                rpv.Controls.AddRange(pag.ToArray());
     
                spa.Panel1.Controls.Add(rpv);
     
                var cn = 0;
                var b1 = new Button() { Text = "Next" };
                b1.Click += (o, e) =>
                {
                    var cpag = rpv.Controls.Cast<RadPageViewPage>().ToList();
                    cpag.ForEach(a => a.Controls.Clear());
                    cpag.ForEach(a => a.Controls.Add(new RadLabel() { Text = (cn++) + "\na\nb\nc\nd\ne\n" }));
     
                    rpv.Width += 1;
                    rpv.Width -= 1;
                };
                spa.Panel2.Controls.Add(b1);
            }
        }
    }


    Thank you for the report. Your Telerik points have been updated.

    Regards,
    Julian Benkov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top