This is a migrated thread and some comments may be shown as answers.
Setting RadGroupBox AutoSizeMode
9 Answers 136 Views
This is a migrated thread and some comments may be shown as answers.
Jonathan Zee
Top achievements
Rank 1
Jonathan Zee asked on 26 May 2009, 05:54 AM
Hi guys,

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

Sort by
0
Nick
Telerik team
answered on 27 May 2009, 10:28 AM
Hi Jonathan Zee,

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.
0
David
Top achievements
Rank 1
answered on 29 Sep 2010, 05:56 PM
Is this still broken?  When is it going to be fixed?  I'm having the exact same problem, and would love to know of a workaround if there is one.  
0
Stefan
Telerik team
answered on 04 Oct 2010, 05:31 PM
Hello David,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David A.
Top achievements
Rank 1
answered on 07 Apr 2011, 08:07 AM
Hello.

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.
0
Stefan
Telerik team
answered on 12 Apr 2011, 04:10 PM
Hi David ,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adam P
Top achievements
Rank 2
answered on 24 Apr 2014, 08:53 AM
Hi, is this still an issue?  I can't find an AutoSIzeMode property
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Apr 2014, 01:45 PM
Hello Adam,

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
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Binshidha
Top achievements
Rank 1
answered on 18 Aug 2020, 07:07 AM

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
           

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Aug 2020, 08:50 AM

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

Asked by
Jonathan Zee
Top achievements
Rank 1
Answers by
Nick
Telerik team
David
Top achievements
Rank 1
Stefan
Telerik team
David A.
Top achievements
Rank 1
Adam P
Top achievements
Rank 2
Dess | Tech Support Engineer, Principal
Telerik team
Binshidha
Top achievements
Rank 1
Share this question
or