Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the size of a Winforms Form titlebar height?

Tags:

c#

.net

winforms

So if it's toolwindow or a minimizable form, I want to be able to get its height programmatically.

Is this possible? If so how?

like image 990
Joan Venge Avatar asked Jan 07 '10 18:01

Joan Venge


People also ask

How do I fix winform size?

Right click on your form and go to properties. Then go to Layout options,see there are a property named Size. Change it as your need as width and length wise.

How do I increase the size of a CheckBox in Winforms?

There's an AutoSize option in the Properties windows; if you turn that off by changing it to False , you will be able to modify the size of your CheckBox .


1 Answers

You can determine titlebar height for both tool-windows and normal forms by using:

Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);  int titleHeight = screenRectangle.Top - this.Top; 

Where 'this' is your form.

ClientRectangle returns the bounds of the client area of your form. RectangleToScreen converts this to screen coordinates which is the same coordinate system as the Form screen location.

like image 61
Ash Avatar answered Sep 21 '22 05:09

Ash