title: How can I dynamically change the size of groupBox when I add new controls in it?
body: <p>Hi my problem is:I create GroupBoxs dynamically and I add into the groupboxs a number of controls in (my case radioButtons ) I'd like the groupboxs to size dynaically in order to display all the RadioButtons that I insert into them. How can I do?
  This is the code:</p>
  
  <pre><code> private void IdEnForm_Load(object sender, EventArgs e)
      {
  
          for (int i = 0; i &lt; a.Count; i++)
          {
  
              for (int j = 0; j &lt; a[i].Count; j++)
              {
                  bool help;
                  if (j == 0) help = true;
                  else help = false;
  
  
                  if (help)
                  {
  
                      gb = new GroupBox();
                      gb.Text = " which Entity you want to mantain?";
                      gb.Font = new Font("Calibri", 12);
                      gb.AutoSize = true;
                      gb.Location = new Point(j * 150, (i + 1) * 100);
  
  
                  }                      
                  RadioButton  rb = new RadioButton();
                  rb.Text=""+  a[i][j];
                  rb.AutoSize = true;
                  gb.Controls.Add(rb);
  
                  this.Controls.Add(gb);
  
                 // MessageBox.Show("" + a[i][j]);
  
              }
  enter code here
  </code></pre>