Introduction to Windows Forms

Defining the Border Style

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 application that can also be minimized to the taskbar and restored in the normal way.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler