HorizontalAlignment Enumeration

 

Specifies how an object or text in a control is horizontally aligned relative to an element of the control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[<ComVisibleAttribute(true)>]
type HorizontalAlignment

Member nameDescription
Center

The object or text is aligned in the center of the control element.

Left

The object or text is aligned on the left of the control element.

Right

The object or text is aligned on the right of the control element.

This enumeration is used in numerous classes. A partial list of these classes is CheckedListBox, ColumnHeader, ComboBox, ControlPaint, Label, ListBox, Control, RichTextBox, and TextBox.

This example shows how to use the HorizontalAlignment enumeration to align the text to the left, right, or in the center of a control element. First, create a TextBox with a specific size, and add a text string to it. Then, use the enumeration member Center to align the text in the center of the TextBox. The example assumes that you have created a Form named Form1 and a TextBox named textBox1.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: