Form Properties

Every form and dialog box is derived from the Form class, which itself is derived from the Control class. Therefore, they share the approximately 100 properties of the Control and Form base classes. Table 5-1 listed many of the most commonly used form properties.

While all of the form properties can be used with either dialog boxes or normal forms, either modal or modeless, several properties are often used to create the "dialog box" look and otherwise control the appearance and behavior of the form. They include those shown in Table 6-1, extracted from Table 5-1 in Chapter 5.

Table 6-1. Form properties often used with dialog boxes

Property

Type

Description

AcceptButton

IButtonControl

Gets or sets the button on a form that is clicked when the user presses Enter, irrespective of which control actually has focus.

BackColor

Color

Gets or sets the background color.

CancelButton

IButtonControl

Gets or sets the button on a form that is clicked when the user presses Escape, irrespective of which control actually has focus.

ControlBox

Boolean

Gets or sets a value indicating if the system menu can be displayed and if the Close button (X) is displayed on the right end of the titlebar. The system menu is exposed by clicking on the icon in the titlebar if the Icon property is set, or by right-clicking on the titlebar if the Icon property is not set. Default is true.

DialogResult

DialogResult

Gets or sets the return value from a form or dialog box displayed modally. ...

Get Programming .NET Windows Applications 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.