开发者

Maintaining the size of the control which is located on the form when form is resized

开发者 https://www.devze.com 2022-12-19 17:48 出处:网络
I have one form which size is (325,325) and on which one browser is there and the size of the browser is (321,298) means browser is in the middle of the form.And I want to maintain the 开发者_Python百

I have one form which size is (325,325) and on which one browser is there and the size of the browser is (321,298) means browser is in the middle of the form.And I want to maintain the 开发者_Python百科size of the browser when form is resized like there should be the same difference of the size between form and browser as it was before resized.


Like the previous answers stated, you should Anchor the control. You should set the Anchor property to Top, Left, Right, Bottom to let the browser grow/shrink when the form is resized, but maintaining the margins.


You should Anchor the control on the form.

Have a look at

  • Manage WinForm controls using the Anchor and Dock properties
  • Control.Anchor Property
  • Manage WinForm controls using the Anchor and Dock properties

Anchoring a control to its parent ensures that the anchored edges remain in the same position relative to the edges of the parent container when the parent container is resized.


Setting the WebBrowser's Dock property to Fill is the correct answer here. This completely eliminates the possibility that you'll have layout problems when you run your program on a machine that has a different system font size or a different video adapter DPI setting.

If you need room for some kind of gadget or toolbar, be sure to dock it as well (usually Top). Use Format + Order if the browser ends up underneath the gadget.


Use the control's Anchor property to anchor it to all 4 edges of the form. The control will automatically change it's size when the parent form resizes then.

The MSDN article explains the basics. Google finds quite a few interesting links as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消