HorizontalAlignment 列挙型

定義

コントロールのオブジェクトまたはテキストをコントロールの要素に合わせて水平方向に配置する場合、どのように配置するのかを指定します。

public enum class HorizontalAlignment
[System.Runtime.InteropServices.ComVisible(true)]
public enum HorizontalAlignment
public enum HorizontalAlignment
[<System.Runtime.InteropServices.ComVisible(true)>]
type HorizontalAlignment = 
type HorizontalAlignment = 
Public Enum HorizontalAlignment
継承
HorizontalAlignment
属性

フィールド

Center 2

オブジェクトまたはテキストは、コントロール要素の中央に配置されます。

Left 0

オブジェクトまたはテキストは、コントロール要素の左側に配置されます。

Right 1

オブジェクトまたはテキストは、コントロール要素の右側に配置されます。

この例では、 列挙を HorizontalAlignment 使用して、コントロール要素の左、右、または中央にテキストを配置する方法を示します。 まず、特定のサイズの を TextBox 作成し、それにテキスト文字列を追加します。 次に、 列挙メンバー Center を使用して、 の中央にテキストを配置します TextBox。 この例では、名前付き と という名前Form1textBox1の がTextBoxForm作成されていることを前提としています。

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;
   }
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;							
}
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

注釈

この列挙は、多数のクラスで使用されます。 これらのクラスの一部の一覧は、CheckedListBoxColumnHeader、、ComboBoxControlPaintListBoxLabelControlRichTextBoxおよび TextBoxです。

適用対象