Form.StartPosition Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the starting position of the form at run time.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member StartPosition : FormStartPosition with get, set

Property Value

Type: System.Windows.Forms.FormStartPosition

A FormStartPosition that represents the starting position of the form.

Exception Condition
InvalidEnumArgumentException

The value specified is outside the range of valid values.

This property enables you to set the starting position of the form when it is displayed at run time. The form’s position can be specified manually by setting the Location property or use the default location specified by Windows. You can also position the form to display in the center of the screen or in the center of its parent form for forms such as multiple-document interface (MDI) child forms.

This property should be set before the form is shown. You can set this property before you call the Show or ShowDialog method or in your form's constructor.

The following code example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box. The example sets the FormBorderStyle, AcceptButton, CancelButton, and StartPosition properties to change the appearance and functionality of the form to a dialog box. The example also uses the Add method of the form's Controls collection to add two Button controls. The example uses the HelpButton property to display a help button in the caption bar of the dialog box.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: