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

RadPageView Auto Size Problem, ExplorerBar Mode – PageViewPage AutoSizeToBestFit

1 Answer 227 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Darryl
Top achievements
Rank 1
Darryl asked on 12 Feb 2013, 07:18 PM

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,

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 15 Feb 2013, 05:13 PM
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.
Tags
PageView
Asked by
Darryl
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or