WindowsFormsApplicationBase.MainForm Property

Definition

Gets or sets the main form for this application.

C#
protected System.Windows.Forms.Form MainForm { get; set; }

Property Value

The main form for this application.

Remarks

Use the MainForm property to get or set the Form object that the Visual Basic Application Startup/Shutdown model uses as the application's main form.

This property supports the Visual Basic Application Startup/Shutdown model. For more information, see Overview of the Visual Basic Application Model.

The changes to this property are not persisted when the application closes. To change the main form permanently, you must change the setting in the Project Designer.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9, 10

See also