Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:27:39+00:00 2026-05-18T01:27:39+00:00

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

  • 0

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

When .NET draws my form at runtime – it draws it 38 pixels high (it adds the height of a title-bar for some reason).

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

To work it around I have 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 this yourself in Visual Studio 2010 (Winforms App, target Framework – 2.0).

Wtf?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:27:39+00:00Added an answer on May 18, 2026 at 1:27 am

    Yeah, it is a bug, of sorts. Note how in the designer you set the size of the form with the Width and Height properties. Those properties include the size of the borders and the title bar. That’s a problem however, your form may run on a machine where the user has increased, say, the title bar font size. That then would reduce the size of the window’s client area. Or in other words, the form’s ClientSize property would change on that machine. Leaving less room for the controls and messing up the design of your form pretty badly.

    There’s code inside the Form class that runs after the Handle is created, right before the Load event runs. It recalculates the Size of the form, using the same ClientSize you had on your machine. Now everything is good, the Height of the form won’t match the one you set in the designer but the form otherwise looks the same and the layout of the controls is identical.

    That same code also ensures that the window doesn’t get too small. And that’s where it falls over, it doesn’t pay enough attention to the FormBorderStyle property. Clipping the height to the title bar size plus the client area height, as you found out. It also prevents the form getting too narrow, trying to make sure that the icon and min/max/close buttons are always visible. Even if you don’t have any.

    The workaround is to change the ClientSize after this code runs, the OnLoad override or Load event handler is the right place for that. Beware that if you hard-code the form size like this then you should also set the AutoScaleMode property to None. Make sure that this doesn’t cause trouble on a machine that has a different DPI setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a borderless form which is always on top and with WS_EX_NOACTIVATE flag
I have code that lets be drag around a borderless form in winforms that
I have a borderless and transparent window in WPF, with some fancy decoration at
I have a C# WinForms borderless window, for which I override WndProc and handle
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have a borderless Windows Forms application. The main window creates other forms (simple
I have a window that does not have a title bar ( WindowStyle ==
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a login.jsp page which contains a login form. Once logged in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.