This is a migrated thread and some comments may be shown as answers.
Panel CanShrink CanGrow
2 Answers 213 Views
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 10 Mar 2009, 03:24 PM
I'm working on a report where I am grouping items together in Panels so that I can correctly dock elements to achieve the right layout.  I have the individual items set to CanShrink = true and CanGrow = true, however the Panels seem to remain the same size.

Is there a way to autosize Panels to their contents?

2 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 13 Mar 2009, 07:59 AM
Hello Jeffrey,

In Telerik Reporting, the default container behavior (such as the Panel report item) is to always wrap its children. This means that the Panel will automatically grow if any of the containing item goes outside its bounds. The opposite is not possible - the Panel won't shrink if its content shrinks.

In order to achieve similar to the required result, we advice you to set the panel and the items inside to have initial size small enough so that they always have to grow. For example all the TextBox items can be 1 text line in height and have the CanGrow enabled (this is by default); with a similar setup the CanShrink won't take any effect so you can leave it as is.

Hope this helps.

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Daniel Mettler
Top achievements
Rank 2
answered on 06 Aug 2013, 12:46 PM
We had the same problem with Panels vertically below each other.
Each has optional items that might be hidden and the wrapper should shrink. This code solved it as suggested by Svetoslav:

private void InitializePanelAutoShrink()
{
    var panels = new List<Telerik.Reporting.Panel>
        {
            pnlFirstGroup,
            pnlSecondGroup,
            pnlThirdGroup
        };
    detail.Height = Unit.Pixel(1);
 
    for (var i = 0; i < panels.Count; i++)
    {
        panels[i].Height = Unit.Pixel(0);
        if (i > 0)
            panels[i].Location = new PointU(Unit.Pixel(0), panels[i - 1].Location.Y.Add(panels[i - 1].Height));
    }
}
Asked by
Jeff
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Daniel Mettler
Top achievements
Rank 2
Share this question
or