Especifica la posición inicial de un formulario.
Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)
Visual Basic (Declaración)
<ComVisibleAttribute(True)> _
Public Enumeration FormStartPosition
Dim instance As FormStartPosition
[ComVisibleAttribute(true)]
public enum FormStartPosition
[ComVisibleAttribute(true)]
public enum class FormStartPosition
/** @attribute ComVisibleAttribute(true) */
public enum FormStartPosition
ComVisibleAttribute(true)
public enum FormStartPosition
| | Nombre de miembro | Descripción |
|---|
| CenterParent | El formulario está centrado en los límites de su formulario principal. |
| CenterScreen | El formulario está centrado en la pantalla actual y tiene las dimensiones especificadas en el tamaño del formulario. |
| Manual | La posición del formulario viene determinado por la propiedad Location. |
| WindowsDefaultBounds | El formulario se encuentra colocado en la ubicación predeterminada de Windows y tiene los límites establecidos por Windows de forma predeterminada. |
| WindowsDefaultLocation | El formulario se encuentra colocado en la ubicación predeterminada de Windows y tiene las dimensiones especificadas en el tamaño del formulario. |
La propiedad StartPosition de la clase Form utiliza esta enumeración. Representa las diferentes posiciones de inicio del formulario. La posición de inicio predeterminada es WindowsDefaultLocation.
En este ejemplo, la posición de inicio del formulario se cambia al centro de la pantalla y se muestra información sobre la posición mediante una etiqueta. En este ejemplo se supone que ya se ha creado un Form denominado Form1.
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 'InitMyForm
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:
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.set_Location(new System.Drawing.Point(54, 128));
label1.set_Name("label1");
label1.set_Size(new System.Drawing.Size(220, 80));
label1.set_Text("Start position information");
this.get_Controls().Add(label1);
// Moves the start position to the center of the screen.
set_StartPosition(FormStartPosition.CenterScreen);
// Displays the position information.
label1.set_Text("The start position is " + get_StartPosition());
} //InitMyForm
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0