Defining the Border Style of the Form

The previous examples are both simple, fixed-size forms that have no minimize or restore button. The border style of the form object controls how a form is shown and if it can be resized.

Listing 3.1.4 shows a very simple Windows Forms application with a sizable client area.

Listing 3.1.4. resize.cs: A Simple Resizable Windows Forms Application
using System;
using System.Drawing;
using System.ComponentModel;
using System.WinForms;
public class SizeApp : System.WinForms.Form
{

    public     SizeApp()
    {
        this.Text = "SizeApp";
        this.MaximizeBox = true;
        this.BorderStyle = FormBorderStyle.Sizable;
    }

    static void Main()
    {
        Application.Run(new SizeApp());
    }

}

Building and running this application will result in a resizable ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.