Allowing ContentPanel to expand to contents

10 posts, 0 answers
  1. Josh Anderson
    Josh Anderson avatar
    83 posts
    Member since:
    Dec 2005

    Posted 01 May 2008 Link to this post

    I'm trying to figure out a way to have a ContentPanel size itself automatically based on the amount of text in a Label control.  I've tried various ways of automatically sizing the Label in hopes that the ContentPanel would enlarge to accommodate the content, and when that failed I tried programmatically changing the size of the GroupElement to match the size of the label.  None of my attempts has been successful.

    Can anyone give me some tips on whether this is possible and if so how to accomplish it?

    Thanks,
    Josh
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 05 May 2008 Link to this post

    Hello Josh,

    Thank you for writing.

    I beleive this functionality would be enabled if you set the AutoSize property of the ContentPanel to true and the AutoSizeMode property to GrowAndShrink (the ContentPanel is actually a standard MS Panel control and this layout-specific behavior is built into it):

    group.ContentPanel.AutoSize =

    true;
    group.ContentPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;

    If you have any additional questions, please contact me.

     
    Sincerely yours,

    Boyko Markov
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Josh Anderson
    Josh Anderson avatar
    83 posts
    Member since:
    Dec 2005

    Posted 05 May 2008 Link to this post

    If only it were that simple!

    The problem comes from an auto-sized component within
    the container.  For my test, I have placed an auto-sized label control with its width constrained to the width of the container.  This enables the text to wrap so that the label can grow downward.  I have set the initial Text property of the label to value that requires about eight or ten lines to display.  I have also placed a button on the form that appends text to the label.

    Not only does the container in fact not accommodate the label's initial long text value, as I click the button to append more text it will not resize.  However, if I collapse the group then re-expand it, the container will expand to the correct size. I believe you can probably replicate this behavior.

    As a side note, for some reason the IDE does not display the AutoSize and AutoSizeMode properties for the Container control, nor does Intellisense display the properties when I attempt to set them via code.  I can manually type them in, however, without an error.  I'm using VS2008 / .NET 3.5.

    Josh
  5. Josh Anderson
    Josh Anderson avatar
    83 posts
    Member since:
    Dec 2005

    Posted 05 May 2008 Link to this post

    Here's an update:

    The hack I have employed so far is to populate the label during the Load event then programmatically un-expand then re-expand the group element.  However, the only way this works, for some reason, is if I put a DoEvents() in between those two calls.  So, this works:

    radPanelBarGroupElement3.Expanded = false;
    Application.DoEvents();
    radPanelBarGroupElement3.Expanded = true;

    But this does not:

    radPanelBarGroupElement3.Expanded = false;
    radPanelBarGroupElement3.Expanded = true;

    I'm not sure why this is...I have to believe there is some sort of bug somewhere.  I've tried calling the Refresh() method on the contentpanel, doing a PerformExpand(), PerformClick(), etc.  The above seems to be the only thing that works.

    Josh
  6. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 06 May 2008 Link to this post

    Hi Josh Anderson,

    Thank you very much about the valuable feedback about RadPanelBar. Is it possible to send me the sample project which is reproducing the behavior you describe. It will help me test and debug the exact case scenario. What panel bar style are you using?

    The code you've sent:

    radPanelBarGroupElement3.Expanded = false;
    Application.DoEvents();
    radPanelBarGroupElement3.Expanded = true;


    seems odd to me, too. Especially the call to DoEvents

    Changing the Expanded property collapses or shows the elements of the RadPanelBarGroupElement, so this is a layout property which forces a layout to be performed. In this case a layout of the ContentPanel is performed which is may be the reason everything works fine after those calls.

    I'm looking forward to your reply.

    All the best,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Josh Anderson
    Josh Anderson avatar
    83 posts
    Member since:
    Dec 2005

    Posted 06 May 2008 Link to this post

    Boyko,

    I created support ticket 136330 and uploaded a sample project with a panelbar set up similar to my application's.  It reproduces the behavior I have described.

    Note that I do not have the DoEvents() hack employed in the sample project.

    Thanks,
    Josh
  8. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 07 May 2008 Link to this post

    Hello Josh Anderson,

    Thank you again for the support ticket 136330.
    Your project was very helpful. I have just responded to it and you can refer to it for more information.

    Please write me if you have more questions.

    Greetings,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Justin
    Justin avatar
    35 posts
    Member since:
    Apr 2008

    Posted 05 Feb 2009 Link to this post

    Is it possible to get information on what was going on here, and resolution?  I am having the exact same issue where content panel is not resizing to height of rad tree view after that control is populated.

    Thanks!
  10. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 06 Feb 2009 Link to this post

    Hi Justin,

    Could you please tell me what is the exact scenario with your PanelBar and how to replicate the issue?
    If it is applicable you can send me a very simple demo application which is showing the issue.

    I'm looking forward to your reply.


    Best wishes,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. Justin
    Justin avatar
    35 posts
    Member since:
    Apr 2008

    Posted 11 Feb 2009 Link to this post

    Boyko, appreciate the offer of assistance - I actually ended up doing something completely different, so will have to revisit this if I run in to it again :)

    Justin
Back to Top
UI for WinForms is Visual Studio 2017 Ready