Is there something special I should be doing when trying to create controls dynamically in order to make 'autosize' work properly ?
For example - if I have something like :
Panel p = new Panel();
Panel p2 = new Panel();
Label l=new Label();
// So we have a label in a panel with a border.
// And that panel in another panel without a border
// but that is autosize..
p.BorderStyle = BorderStyle.Fixed3D;
// p.AutoSize = true;
// p2.AutoSize = true;
l.Text = "Hello";
l.AutoSize = true;
l.BackColor = Color.Red;
p.BackColor = Color.Blue;
p2.BackColor = Color.Green;
p.Controls.Add(l);
p2.Controls.Add(p);
p.Top = 40;
p.Left = 40;
p.AutoSize = true;
p2.AutoSize = true;
this.Controls.Add(p2);
(just put in a button click on a blank form)
Running it - you should see the panels are too large for the label..
(Doesn't seem to matter if I set the 'autosize' before or after )
Now - in practice - I've got some very complicated forms generated - with flowlayouts etc - but the Autosizing isn't working properly in similar ways, including not allocating enough space for the borders on some of the contained controls etc..
Any thoughts ?
As an alternative - is there someway to force a resize to a control and all its children ?
(For reference - I had major problems in 6.3 with this too - including having to set the size to something massive adding child controls, and then setting autosize)