Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Esta página es específica de
Microsoft Visual Studio 2008/.NET Framework 3.5

Hay además otras versiones disponibles para:
Biblioteca de clases de .NET Framework
HorizontalAlignment (Enumeración)

Actualización: noviembre 2007

Especifica cómo se alinea horizontalmente un objeto o texto de un control con respecto a un elemento del control.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Visual Basic (Declaración)
<ComVisibleAttribute(True)> _
Public Enumeration HorizontalAlignment
Visual Basic (Uso)
Dim instance As HorizontalAlignment
C#
[ComVisibleAttribute(true)]
public enum HorizontalAlignment
Visual C++
[ComVisibleAttribute(true)]
public enum class HorizontalAlignment
J#
/** @attribute ComVisibleAttribute(true) */
public enum HorizontalAlignment
JScript
public enum HorizontalAlignment
Nombre de miembroDescripción
w4d1hwsw.CFW(es-es,VS.90).gifLeftEl objeto o texto se alinea a la izquierda del elemento del control.
w4d1hwsw.CFW(es-es,VS.90).gifRightEl objeto o texto se alinea a la derecha del elemento del control.
w4d1hwsw.CFW(es-es,VS.90).gifCenterEl objeto o texto se alinea en el centro del elemento del control.

Esta enumeración se utiliza en numerosas clases. Una lista parcial de estas clases incluye CheckedListBox, ColumnHeader, ComboBox, ControlPaint, Label, ListBox, Control, RichTextBox y TextBox.

En este ejemplo se muestra cómo utilizar la enumeración HorizontalAlignment para alinear el texto a la izquierda, derecho o en el centro de un elemento de control. Primero, se crea un TextBox con un tamaño específico, y se le agrega una cadena de texto. A continuación, se utiliza el miembro de la enumeración Center para alinear el texto en el centro de TextBox. En este ejemplo se supone que se ha creado un Form denominado Form1 y un TextBox denominado textBox1.

Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' Add a text string to the TextBox.
    TextBox1.Text = "Hello World!"

    ' Set the size of the TextBox.
    TextBox1.AutoSize = False
    TextBox1.Size = New Size(Width, Height/3)

    ' Align the text in the center of the control element. 
    TextBox1.TextAlign = HorizontalAlignment.Center
End Sub
C#
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Add a text string to the TextBox.
            textBox1.Text = "Hello World!";
            
            // Set the size of the TextBox.
            textBox1.AutoSize = false;
            textBox1.Size = new Size(Width, Height/3);
            
            // Align the text in the center of the control element. 
            textBox1.TextAlign = HorizontalAlignment.Center;                            
        }
Visual C++
private:
   void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Add a text String* to the TextBox.
      textBox1->Text = "Hello World!";

      // Set the size of the TextBox.
      textBox1->AutoSize = false;
      textBox1->Size = System::Drawing::Size( Width, Height / 3 );

      // Align the text in the center of the control element.
      textBox1->TextAlign = HorizontalAlignment::Center;
   }
J#
private void Form1_Load(Object sender, System.EventArgs e)
{
    // Add a text string to the TextBox.
    textBox1.set_Text("Hello World!");

    // Set the size of the TextBox.
    textBox1.set_AutoSize(false);
    textBox1.set_Size(new Size(get_Width(), get_Height() / 3));

    // Align the text in the center of the control element. 
    textBox1.set_TextAlign(HorizontalAlignment.Center);
} //Form1_Load

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 3.5, 2.0, 1.0
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker