Form.StartPosition Property
Gets or sets the starting position of the form at run time.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System.Windows.Forms.FormStartPositionA 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.
Available since 1.1