Click here to Skip to main content
15,900,685 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi How i can get Form size?(Current size )i.e even when resize form i can get size form
thanks.
Posted

Simply call the Size Property[^] of your Form[^]...
int width = this.Size.Width;
int height = this.Size.Height;
 
Share this answer
 
Comments
f.zeinali 21-Oct-11 14:32pm    
thanks
Sander Rossel 21-Oct-11 14:39pm    
No problem. To get this when a Form resizes handle the Resize Event of your Form, like André said. The same code will still apply though.
Use the Size property[^] of the Form class[^].

To get the size after the size has been changed you need to handle the Resize event[^] of the Form.
 
Share this answer
 
v3
Every Control (and a Form is derived from Control) has a Size property which you can access or set at any time. In your form code, just use Size as a normal variable.

When the form size is changed, you can handle an event (the Resize event, predictably enough) which lets you do what you want as a result. Be aware though, that if you change the form size in the Resize event, that will cause another Resize event, and so on...
 
Share this answer
 
You can track when a form is being resized by the user by using one of the many Form events ( http://msdn.microsoft.com/en-us/library/system.windows.forms.form_events.aspx[^]) one of which is the Resize event which form inherited from control http://msdn.microsoft.com/en-us/library/system.windows.forms.control.resize.aspx[^].

The Size property which is also inherited from control can then be polled inside the event handler.

Regareds,

—MRB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900