FormStartPosition 列舉

定義

指定表單的初始位置。

public enum class FormStartPosition
[System.Runtime.InteropServices.ComVisible(true)]
public enum FormStartPosition
public enum FormStartPosition
[<System.Runtime.InteropServices.ComVisible(true)>]
type FormStartPosition = 
type FormStartPosition = 
Public Enum FormStartPosition
繼承
FormStartPosition
屬性

欄位

CenterParent 4

表單出現在其父表單界限內的中央。

CenterScreen 1

表單出現在目前顯示的中央,並且具有在表單大小中所指定的尺寸。

Manual 0

表單的位置是由 Location 屬性決定。

WindowsDefaultBounds 3

表單放置在 Windows 預設位置,並且具有由 Windows 預設值所決定的界限。

WindowsDefaultLocation 2

表單放置在 Windows 預設位置,並且具有在表單大小中所指定的尺寸。

範例

在此範例中,您會將表單的開始位置變更為畫面的中心,並使用標籤顯示位置資訊。 此範例假設您已經建立名為 的 Form Form1

public:
   void InitMyForm()
   {
      // Adds a label to the form.
      Label^ label1 = gcnew Label;
      label1->Location = System::Drawing::Point( 54, 128 );
      label1->Name = "label1";
      label1->Size = System::Drawing::Size( 220, 80 );
      label1->Text = "Start position information";
      this->Controls->Add( label1 );
      
      // Moves the start position to the center of the screen.
      StartPosition = FormStartPosition::CenterScreen;
      
      // Displays the position information.
      label1->Text = String::Format( "The start position is {0}", StartPosition );
   }
public void InitMyForm()
{
    // Adds a label to the form.
    Label label1 = new Label();
    label1.Location = new System.Drawing.Point(54, 128);
    label1.Name = "label1";
    label1.Size = new System.Drawing.Size(220, 80);
    label1.Text = "Start position information";
    this.Controls.Add(label1);

    // Moves the start position to the center of the screen.
    StartPosition = FormStartPosition.CenterScreen;
    // Displays the position information.
    label1.Text = "The start position is " + StartPosition;	
}
Public Sub InitMyForm()
   ' Adds a label to the form.
   Dim label1 As New Label()
   label1.Location = New System.Drawing.Point(54, 128)
   label1.Name = "label1"
   label1.Size = New System.Drawing.Size(220, 80)
   label1.Text = "Start position information"
   Me.Controls.Add(label1)
   
   ' Moves the start position to the center of the screen.
   StartPosition = FormStartPosition.CenterScreen
   ' Displays the position information.
   label1.Text = "The start position is " + StartPosition
End Sub

備註

這個列舉是由 StartPosition 類別的 Form 屬性使用。 它代表表單的不同開始位置。 預設的開始位置為 WindowsDefaultLocation

適用於

另請參閱