Unplanned
Last Updated: 22 Sep 2017 12:27 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 14 Jan 2015 17:21
Category:
Type: Bug Report
4
FIX. RadCollapsiblePanel - ContentSizingMode property does not affect the panel size when the inner controls need more space than the current panel size

To reproduce: add a RadCollapsiblePanel and insert several controls at run time with specifying the location and size of the inner controls. Set the ContentSizingMode property to CollapsiblePanelContentSizingMode.FitToContentHeight | CollapsiblePanelContentSizingMode.FitToContentWidth. When you run the application you will notice that the inner controls are cut off and the panel is not resized according to its content.

Workaround:

Before:

After:

        public RadForm2()
        {
            InitializeComponent(); 

            this.radCollapsiblePanel1.ContentSizingMode = CollapsiblePanelContentSizingMode.None;
        }

        private void RadForm2_Load(object sender, EventArgs e)
        { 
            SizeF fillElementSize = this.radCollapsiblePanel1.Size;
            int maxY = int.MinValue;
            int maxX = int.MinValue;
            int maxControlWidth = int.MinValue;
            int maxControlHeight = int.MinValue;
            bool fitToHeight = true;
            bool fitToWidth = true;

            Padding panelContainerPadding = this.radCollapsiblePanel1.ControlsContainer.PanelContainer.Padding;
            foreach (Control control in this.radCollapsiblePanel1.ControlsContainer.PanelContainer.Controls)
            {
                if (fitToHeight)
                {
                    maxY = Math.Max(maxY, control.Bounds.Location.Y + control.Bounds.Size.Height + control.Margin.Bottom + panelContainerPadding.Bottom +
                                          this.radCollapsiblePanel1.ControlsContainer.VerticalScrollbar.Value);
                    maxControlWidth = Math.Max(maxControlWidth, control.Width);
                }

                if (fitToWidth)
                {
                    maxX = Math.Max(maxX, control.Bounds.Location.X + control.Bounds.Size.Width + control.Margin.Right + panelContainerPadding.Right +
                                          this.radCollapsiblePanel1.ControlsContainer.HorizontalScrollbar.Value);
                    maxControlHeight = Math.Max(maxControlHeight, control.Height);
                }
            }

            if (fitToHeight)
            {
                bool horizontalScrollbarNeeded = fillElementSize.Width <= maxY + maxControlWidth;
                if (horizontalScrollbarNeeded)
                {
                    this.radCollapsiblePanel1.ControlsContainer.HorizontalScrollBarState = ScrollState.AlwaysHide;
                }
                else
                {
                    this.radCollapsiblePanel1.ControlsContainer.HorizontalScrollBarState = ScrollState.AutoHide;
                }

                fillElementSize.Height = maxY;
            }

            if (fitToWidth)
            {
                bool verticalScrollbarNeeded = fillElementSize.Height <= maxX + maxControlHeight;
                if (verticalScrollbarNeeded)
                {
                    this.radCollapsiblePanel1.ControlsContainer.VerticalScrollBarState = ScrollState.AlwaysHide;
                }
                else
                {
                    this.radCollapsiblePanel1.ControlsContainer.VerticalScrollBarState = ScrollState.AutoHide;
                }

                fillElementSize.Width = maxX;
            }
            fillElementSize.Height += this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Size.Height + 5;
             
            this.radCollapsiblePanel1.MinimumSize = this.radCollapsiblePanel1.MaximumSize = this.radCollapsiblePanel1.Size = fillElementSize.ToSize();
        }

2 comments
ADMIN
Stefan
Posted on: 04 Feb 2015 11:18
No, I don't think these are related.
Michele
Posted on: 22 Jan 2015 11:26
Hello is this related to the iussue addressed here ?  http://www.telerik.com/account/VersionNotes.aspx?nb=1&id=2561

RadScrollablePanel

FIXED: Anchored controls inside RadScrollablePanel are not sized correctly when the form loads.

?
Thanks