TextBox.TextAlign Özellik

Tanım

Metnin denetimde TextBox nasıl hizalı olduğunu alır veya ayarlar.

public:
 property System::Windows::Forms::HorizontalAlignment TextAlign { System::Windows::Forms::HorizontalAlignment get(); void set(System::Windows::Forms::HorizontalAlignment value); };
public System.Windows.Forms.HorizontalAlignment TextAlign { get; set; }
member this.TextAlign : System.Windows.Forms.HorizontalAlignment with get, set
Public Property TextAlign As HorizontalAlignment

Özellik Değeri

HorizontalAlignment

Metnin denetimde HorizontalAlignment nasıl hizalandığını belirten numaralandırma değerlerinden biri. Varsayılan değer: HorizontalAlignment.Left.

Özel durumlar

Sabit listesi için geçerli değerler aralığında olmayan bir değer özelliğine atandı.

Örnekler

Aşağıdaki kod örneği, parola TextBox kabul etmek için kullanılan bir denetim oluşturur. Bu örnek, küçük harfe yazılan tüm karakterleri değiştirmek için özelliğini ve MaxLength parola uzunluğunu sekiz karakterle kısıtlamak için özelliğini kullanırCharacterCasing. Bu örnek, denetimindeki parolayı TextAlign TextBox ortalamak için özelliğini de kullanır.

public:
   void CreateMyPasswordTextBox()
   {
      // Create an instance of the TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      // Set the maximum length of text in the control to eight.
      textBox1->MaxLength = 8;
      // Assign the asterisk to be the password character.
      textBox1->PasswordChar = '*';
      // Change all text entered to be lowercase.
      textBox1->CharacterCasing = CharacterCasing::Lower;
      // Align the text in the center of the TextBox control.
      textBox1->TextAlign = HorizontalAlignment::Center;
   }
public void CreateMyPasswordTextBox()
 {
    // Create an instance of the TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the maximum length of text in the control to eight.
    textBox1.MaxLength = 8;
    // Assign the asterisk to be the password character.
    textBox1.PasswordChar = '*';
    // Change all text entered to be lowercase.
    textBox1.CharacterCasing = CharacterCasing.Lower;
    // Align the text in the center of the TextBox control.
    textBox1.TextAlign = HorizontalAlignment.Center;
 }
Public Sub CreateMyPasswordTextBox()
    ' Create an instance of the TextBox control.
    Dim textBox1 As New TextBox()
    ' Set the maximum length of text in the control to eight.
    textBox1.MaxLength = 8
    ' Assign the asterisk to be the password character.
    textBox1.PasswordChar = "*"c
    ' Change all text entered to be lowercase.
    textBox1.CharacterCasing = CharacterCasing.Lower
    ' Align the text in the center of the TextBox control.
    textBox1.TextAlign = HorizontalAlignment.Center
End Sub

Açıklamalar

Bu özelliği kullanarak içindeki metni TextBox formunuzun düzeniyle eşleşecek şekilde hizalayabilirsiniz. Örneğin, tüm denetimleriniz formun sağ tarafında yer alıyorsa, özelliğini olarak HorizontalAlignment.Rightayarlayabilirsiniz TextAlign ve metin varsayılan sol hizalama yerine denetimin sağ tarafına hizalanır.

Şunlara uygulanır

Ayrıca bkz.