HorizontalAlignment 列挙体
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<ComVisibleAttribute(True)> _ Public Enumeration HorizontalAlignment

メンバ名 | 説明 | |
---|---|---|
![]() | Center | オブジェクトまたはテキストは、コントロール要素の中央に配置されます。 |
![]() | Left | オブジェクトまたはテキストは、コントロール要素の左側に配置されます。 |
![]() | Right | オブジェクトまたはテキストは、コントロール要素の右側に配置されます。 |

この列挙体は、さまざまなクラスで使用されます。これらに含まれるクラスの部分リストは CheckedListBox、ColumnHeader、ComboBox、ControlPaint、Label、ListBox、Control、RichTextBox、TextBox などです。

この例では、HorizontalAlignment 列挙体を使用して、テキストをコントロール要素の左、右、または中央に配置する方法を示しています。最初に、特定のサイズの TextBox を作成して、文字列を追加します。次に、この列挙体のメンバ Center を使用して、テキストを TextBox の中央に配置します。この例は、Form1 という名前の Form と textBox1 という名前の TextBox が作成済みであることを前提にしています。
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
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: 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.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 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHorizontalAlignment 列挙体を検索する場合は、下記のリンクをクリックしてください。

- HorizontalAlignment 列挙体のページへのリンク