Panel CanShrink CanGrow

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    66 posts
    Member since:
    May 2005

    Posted 10 Mar 2009 Link to this post

    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. Svetoslav
    Svetoslav avatar
    649 posts

    Posted 13 Mar 2009 Link to this post

    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,
    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.
  3. Daniel Mettler
    Daniel Mettler avatar
    21 posts
    Member since:
    Apr 2003

    Posted 06 Aug 2013 Link to this post

    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>
        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));
Back to Top