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

Allowing ContentPanel to expand to contents

9 Answers 178 Views
Panelbar (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Josh Anderson
Top achievements
Rank 1
Josh Anderson asked on 01 May 2008, 03:38 PM
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

9 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 05 May 2008, 01:04 PM
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
0
Josh Anderson
Top achievements
Rank 1
answered on 05 May 2008, 03:02 PM
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
0
Josh Anderson
Top achievements
Rank 1
answered on 05 May 2008, 03:33 PM
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
0
Boyko Markov
Telerik team
answered on 06 May 2008, 07:28 AM
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
0
Josh Anderson
Top achievements
Rank 1
answered on 06 May 2008, 02:09 PM
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
0
Boyko Markov
Telerik team
answered on 07 May 2008, 12:08 PM
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
0
Justin
Top achievements
Rank 1
answered on 05 Feb 2009, 10:34 PM
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!
0
Boyko Markov
Telerik team
answered on 06 Feb 2009, 10:24 AM
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.
0
Justin
Top achievements
Rank 1
answered on 11 Feb 2009, 06:50 PM
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
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
Josh Anderson
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Josh Anderson
Top achievements
Rank 1
Justin
Top achievements
Rank 1
Share this question
or