How do I make a child control re-anchor to its parent Form when it has been cut off on a small resol

Posted by Paul Fedory on Stack Overflow See other posts from Stack Overflow or by Paul Fedory
Published on 2009-07-09T16:29:24Z Indexed on 2010/03/09 3:06 UTC
Read the original article Hit count: 295

Filed under:
|

I have a Windows Form with a default size of 1100 x 400, and I have a DataGridView control on it anchored to Top, Left, Bottom, Right.

Resizing the form on a screen with resolution higher than 1100 x 400 works fine, and the anchoring works well, resizing the DataGridView control as expected.

When I launch the form on a screen with resolution 800x600, the form is cut off, and made to fit the 800 x 600. The DataGridView is cut off, and cannot be seen entirely - it bleeds off the form to the right, so it's not respecting the right anchor. Resizing the form in this situation doesn't respect the anchoring settings for some reason: the DataGridView control does not resize when the form is resized.

Is there a way programmatically (on a resize event or something) to force the child DataGridView control to anchor to the sides of the form?

I've already tried calling a PerformLayout and Refresh in the Form's resize event but it's rather redundant, isn't it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms