HorizontalAlignment 列挙型
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コントロール内のオブジェクトまたはテキストをコントロールの要素に対して水平方向に配置する方法を指定します。
public enum class HorizontalAlignment
[System.Runtime.InteropServices.ComVisible(true)]
public enum HorizontalAlignment
[<System.Runtime.InteropServices.ComVisible(true)>]
type HorizontalAlignment =
Public Enum HorizontalAlignment
- 継承
- 属性
フィールド
| 名前 | 値 | 説明 |
|---|---|---|
| Left | 0 | オブジェクトまたはテキストは、コントロール要素の左側に配置されます。 |
| Right | 1 | オブジェクトまたはテキストは、コントロール要素の右側に配置されます。 |
| Center | 2 | オブジェクトまたはテキストは、コントロール要素の中央に配置されます。 |
例
この例では、 HorizontalAlignment 列挙体を使用して、コントロール要素の左、右、または中央にテキストを配置する方法を示します。 まず、特定のサイズの TextBox を作成し、それにテキスト文字列を追加します。 次に、列挙メンバー Center を使用して、 TextBoxの中央にテキストを配置します。 この例では、Form1という名前のFormと、textBox1という名前のTextBoxを作成していることを前提としています。
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
注釈
この列挙型は、多数のクラスで使用されます。 これらのクラスの一部のリストは、 CheckedListBox、 ColumnHeader、 ComboBox、 ControlPaint、 Label、 ListBox、 Control、 RichTextBox、および TextBoxです。