How do I set the size of the visible area of a form, minus heading and borders?

Mocco picture Mocco · Feb 24, 2011 · Viewed 27.9k times · Source

I would like to set my form to be exactly 300*300 excluding heading and borders.

If I use Size property, it does include these values.

Is there any way how to do it?

Answer

Yetti picture Yetti · Feb 24, 2011

You have two options, as follows:

  • To remove heading and borders from a Form, disable the Form's FormBorderStyle property.

  • Set the interior of the form with the ClientSize property, as follows:

    this.ClientSize = new Size(300, 300);