The problem with the height of the form in the absence of the form FormBorderStyle

I have a borderless form (FormBorderStyle = None) with a height of 23 pixels (set in the designer)

When .NET draws my form at runtime, it draws a maximum of 38 pixels (for some reason, it adds a header height).

MessageBox.Show(this.Height.ToString()); //this shows 38!! why?

To work around, I need to set "Height = 23;" in the Form_Load event.

private void MyForm_Load(object sender, EventArgs e)
{
    this.Height = 23; //workaround. wtf??
}

You can try it yourself in Visual Studio 2010 (Winforms App, target Framework - 2.0).

Wtf?

+3
source share
1 answer

, . , Width Height. . , , , , . . , , ClientSize . .

Form, Handle, Load. , ClientSize, . , , , , .

, . , , FormBorderStyle. , . , , min/max/close . .

ClientSize , OnLoad Load. , , , AutoScaleMode None. , , DPI.

+5

Source: https://habr.com/ru/post/1774488/


All Articles