windows forms - how to get the size of an autosized control

  • Thread starter Thread starter BillE
  • Start date Start date
B

BillE

I'm using VS2008, windows forms.

If I have a panel (for example) which has the Autosize property true, how
can I get its new size after it is populated with controls and resized?

The "size" property returns the initial size, even after it has resized to a
larger size.

Thanks
Bill
 
I'm using VS2008, windows forms.

If I have a panel (for example) which has the Autosize property true, how
can I get its new size after it is populated with controls and resized?

The "size" property returns the initial size, even after it has resized to a
larger size.

Are you sure it had actually resized? For example, if it's
Visible==false at the moment, I don't see any reason for it to resize
immediately after you've added a few controls to it - it will probably
delay all layout logic at least until the control handle gets created.
If that's the case, try calling CreateHandle() on the panel, and see
if that helps.

If you can actually see the panel being resized, but Size still
returns the wrong value, than it is certainly a bug, and you should
file it at https://connect.microsoft.com/VisualStudio/Feedback
 
Back
Top