StringAlignment Enumeration

 

Specifies the alignment of a text string relative to its layout rectangle.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

type StringAlignment

Member nameDescription
Center

Specifies that text is aligned in the center of the layout rectangle.

Far

Specifies that text is aligned far from the origin position of the layout rectangle. In a left-to-right layout, the far position is right. In a right-to-left layout, the far position is left.

Near

Specifies the text be aligned near the layout. In a left-to-right layout, the near position is left. In a right-to-left layout, the near position is right.

When used with the LineAlignment property, this enumeration sets the vertical alignment for a drawn string. When used with the Alignment property, this enumeration sets the horizontal alignment.

The following code example demonstrates how to use the LineAlignment and Alignment properties and the StringAlignment enumeration to align strings. This example is designed to be used with Windows Forms. Paste the code into a form and call the ShowLineAndAlignment method when handling the form's Paint event, passing e as PaintEventArgs .

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

.NET Framework
Available since 1.1
Return to top
Show: