O'Reilly logo

.NET Windows Forms in a Nutshell by Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Form

Synopsis

A Form is a specialization of Control that supports top-level windows such as tool windows, frame windows, application pop-ups, and MDI child windows.

The appearance of the form’s non-client imagery can be set using the FormBorderStyle to determine the basic appearance, along with the SizeGripStyle to determine whether to show the resizing grippy. The non-client controls are enabled and disabled with the ControlBox (which enables the system menu and close button), MaximizeBox, MinimizeBox, and HelpButton properties. You can also set the Icon to use for the ControlBox.

The Form can also show a Menu, and a MergedMenu can be retrieved for the current context if you are using the MDI idiom.

You can create and Show() a form modelessly as with any other control, or use the ShowDialog() method to create and show a modal window. The Modal property can be used to determine which method is used to display the form. How the Form is initially positioned is determined by the StartPosition property. You can subsequently minimize or maximize the form by setting the WindowState. It will float above all other windows if you set TopMost to true. While it is showing, it can be made to appear in the taskbar by setting the ShowInTaskbar property.

When the Form is closed, the ShowDialog() method returns the DialogResult.

Default button processing is handled through the AcceptButton and CancelButton properties. You can assign any IButtonControl-derived class to this property (which includes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required