I'm in the process of converting all existing WinForm GroupBoxes to RadGroupBoxes programatically. However there's a property called AutoSizeMode that's missing and I need some help to resize a groupbox based on the number of controls in it.
The code that I'm working with now is
GroupBox dbGroupBox = new GroupBox(); | |
dbGroupBox.Location = new System.Drawing.Point(10, 0); | |
dbGroupBox.Name = databaseInstance + pageName; | |
dbGroupBox.TabIndex = 0; | |
dbGroupBox.TabStop = false; | |
dbGroupBox.Text = pageTitle + " (Possible Matchs)"; | |
dbGroupBox.AutoSize = true; | |
dbGroupBox.AutoSizeMode = AutoSizeMode.GrowOnly; | |
dbGroupBox.Tag = tag.ToString(); | |
dbGroupBox.BackColor = Color.Transparent; |
and I need to convert it into
RadGroupBox dbGroupBox = new RadGroupBox(); | |
dbGroupBox.Location = new System.Drawing.Point(460, groupBoxY); | |
dbGroupBox.Name = databaseInstance + pageName; | |
dbGroupBox.TabIndex = 0; | |
dbGroupBox.TabStop = false; | |
dbGroupBox.Text = pageTitle + " (Possible Matchs)"; | |
dbGroupBox.AutoSize = true; | |
//dbGroupBox.AutoSizeMode = AutoSizeMode.GrowOnly; | |
dbGroupBox.Tag = tag.ToString(); | |
dbGroupBox.BackColor = Color.Transparent; |
Note that line 8 has been commented out because there's no AutoSizeMode in a RadGroupBox. Can you advise on how I can toggle a resize on the Groupbox based on the number of controls within the box? (i.e. the controls are generated dynamically.)
Thanks
9 Answers, 1 is accepted
Thank you for your question. Unfortunately, while AutoSize property is present, there is a bug and hence our RadGroupBox controls behaves differently than the standard GroupBox. For the time being, I can only suggest the work-around of setting RadGroupBox size manually when you add controls to its Controls collection. You need to take into consideration the location and the size of your dynamically added controls and expand the control accordingly. Please excuse us for the introduced inconvenience.
Best wishes,
Nick
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.
Thank you very much for raising this question again.
Currently, I cannot provide you with a specific time frame when this case will be covered. There are features and fixes with higher priority due to their higher popularity within our community. This is why this issue is not yet scheduled fox fixing
However, you can work around this behavior by following the suggestion of my colleague Nick.
Should you have any other questions, do not hesitate to contact me.
Kind regards,
Stefan
the Telerik team
I am experiencing the same grief with this. I have a tablelayoutpanel inside a RadGroupBox and setting RadGroupBox.AutoSize doesn't do anything. I have to manually set the height for each instance this occurs. A fix would be very nice. Thank you.
Thank you for writing.
Please find this issue PITS item at this link. You can subscribe for its status updates and also you can add your vote for it.
Best wishes,
Stefan
the Telerik team
Thank you for writing.
We have introduced a fix for the referred issue in Q1 2013 (version 2013.1.220). For reference, here is the Feedback Item. I would like to note that the issue is related to the RadGroupBox.AutoSize property, not to the AutoSizeMode property, which is relevant for the GroupBoxElement. Here is a sample code snippet:
public
Form1()
{
InitializeComponent();
this
.radGroupBox1.AutoSize =
true
;
for
(
int
i = 0; i < 10; i++)
{
RadButton btn =
new
RadButton();
btn.Text =
"Button"
+ i;
btn.Location =
new
Point(radGroupBox1.Location.X, radGroupBox1.Location.Y + i * 25 + 5);
this
.radGroupBox1.Controls.Add(btn);
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Hi,
Any fix for AutoSizeMode available?
I have winform property as
Me.grp.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink,
I need to convert this to radgroup box.
Is any option available in visual style builder?
Regards,
Binshidha K
Hello, Binshidha,
The fix regarding the AutoSize property of RadGroupBox was introduced back in Q1 2013 version. Regarding the AutoSizeMode property, RadGroupBox still doesn't offers such a property. However, the controls is auto-sized in a similar way as System.Windows.Forms.AutoSizeMode.GrowAndShrink.
Here is my sample code snippet which result is illustrated in the below screenshots:
public RadForm1()
{
InitializeComponent();
this.groupBox1.AutoSize = true;
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.radGroupBox1.AutoSize = true;
for (int i = 0; i < 10; i++)
{
RadButton btn = new RadButton();
btn.Text = "Button" + i;
btn.Location = new Point(10, radGroupBox1.Location.Y + i * 25 + 5);
this.radGroupBox1.Controls.Add(btn);
Button b = new Button();
b.Text = "Button" + i;
b.Location = new Point(10, groupBox1.Location.Y + i * 25 + 5);
this.groupBox1.Controls.Add(b);
}
}
I believe that this behavior would be suitable for your case. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik