Form Properties

Since every form is derived from the Form class, which itself is derived from the Control class, they have all the properties of the Control and Form base classes, of which there are about one hundred. Many of the most commonly used properties are listed in Table 5-1. These properties can either be set in Visual Studio .NET at design time or set programmatically at runtime.

Table 5-1. Form properties

Property

Value 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.

ActiveForm

Form

Static property (shared in VB.NET) that gets the currently active form. Returns null (Nothing in VB.NET) if there is no active form.

ActiveMdiChild

Form

Gets currently active MDI child. Returns null (Nothing in VB.NET) if there is no active form. Allows operations on MDI child forms from MDI parent form, or determination if any open MDI child forms.

AutoScroll

Boolean

If set true, the default, scrollbars will automatically display if any controls are outside the form's client region.

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.

ClientSize

Size

Gets or sets the size of the area of the form excluding the borders and titlebar.

ControlBox

Boolean

Gets or sets a value indicating if the ...

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.