How to obtain form's inner width and height

2019-02-16 12:03发布

As per title.

I am writing a program that all components can adjust size automatically by form's size.

When I using this.Width and this.Height properties, its return value is the width and height of whole form (red frame).

How to get the form's width and height of its inner area (green frame)?

2条回答
Lonely孤独者°
2楼-- · 2019-02-16 12:29

Use this.ClientSize.Width and this.ClientSize.Height.

http://msdn.microsoft.com/en-us/library/9278sfx2(v=vs.110).aspx

查看更多
做个烂人
3楼-- · 2019-02-16 12:45

Yes, You can check by this.ClientSize.Width and this.ClientSize.Height. Or you can put Panel in form and Dock fill and get this.panel1.width/ this.panel1.height as well.

查看更多
登录 后发表回答