The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TextFormatFlags Enumeration

Specifies the display and layout information for text strings.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

public enum TextFormatFlags
/** @attribute FlagsAttribute() */ 
public enum TextFormatFlags
public enum TextFormatFlags

 Member nameDescription
BottomAligns the text on the bottom of the bounding rectangle. Applied only when the text is a single line. 
DefaultApplies the default formatting, which is left-aligned. 
EndEllipsisRemoves the end of trimmed lines, and replaces them with an ellipsis. 
ExpandTabsExpands tab characters. The default number of characters per tab is eight. The WordEllipsis, PathEllipsis, and EndEllipsis values cannot be used with ExpandTabs
ExternalLeadingIncludes the font external leading in line height. Typically, external leading is not included in the height of a line of text. 
GlyphOverhangPaddingAdds padding to the bounding rectangle to accommodate overhanging glyphs.  
HidePrefixApplies to Windows 2000 and Windows XP only:  

Ignores the ampersand (&) prefix character in the text. The letter that follows will not be underlined, but other mnemonic-prefix characters are still processed. For example, an input string of "A&bc&&d" with HidePrefix applied would result in output of "Abc&d".

Compare with NoPrefix and PrefixOnly.

HorizontalCenterCenters the text horizontally within the bounding rectangle. 
InternalUses the system font to calculate text metrics. 
LeftAligns the text on the left side of the clipping area. 
LeftAndRightPaddingAdds padding to both sides of the bounding rectangle. 
ModifyStringHas no effect on the drawn text. 
NoClippingAllows the overhanging parts of glyphs and unwrapped text reaching outside the formatting rectangle to show. 
NoFullWidthCharacterBreakApplies to Windows 98, Windows Me, Windows 2000, or Windows XP only: 

Prevents a line break at a double-wide character string, so that the line-breaking rule is equivalent to single-wide character strings. For example, NoFullWidthCharacterBreak increases the readability of icon labels in Korean windows. This value has no effect unless WordBreak is also specified.

NoPaddingDoes not add padding to the bounding rectangle. 
NoPrefixTurns off processing of prefix characters. Typically, the ampersand (&) mnemonic-prefix character is interpreted as a directive to underscore the character that follows, and the double-ampersand (&&) mnemonic-prefix characters as a directive to print a single ampersand. By specifying NoPrefix, this processing is turned off. For example, an input string of "A&bc&&d" with NoPrefix applied would result in output of "A&bc&&d". 

Compare with HidePrefix and PrefixOnly.

PathEllipsisRemoves the center of trimmed lines and replaces it with an ellipsis.  
PrefixOnlyApplies to Windows 2000 or Windows XP only:  

Draws only an underline at the position of the character following the ampersand (&) prefix character. Does not draw any other characters in the string. For example, an input string of "A&bc&&d" would result in output of " _ ".

Compare with HidePrefix and NoPrefix.

PreserveGraphicsClippingPreserves the clipping specified by a Graphics object. Applies only to methods receiving an IDeviceContext that is a Graphics
PreserveGraphicsTranslateTransformPreserves the transformation specified by a Graphics. Applies only to methods receiving an IDeviceContext that is a Graphics
RightAligns the text on the right side of the clipping area. 
RightToLeftDisplays the text from right to left. 
SingleLineDisplays the text in a single line. 
TextBoxControlSpecifies the text should be formatted for display on a TextBox control. 
TopAligns the text on the top of the bounding rectangle. 
VerticalCenterCenters the text vertically, within the bounding rectangle. 
WordBreakBreaks the text at the end of a word. 
WordEllipsisTrims the line to the nearest word and an ellipsis is placed at the end of a trimmed line. 

The TextFormatFlags enumeration is used by the TextRenderer when drawing and measuring text. The TextRenderer does not support adding tab stops to drawn text, although you can expand existing tab stops using the ExpandTabs flag.

The following code example demonstrates how to use the TextFormatFlags enumeration. To run this example, paste the following code into a Windows Form. Call RenderText7 from the form's Paint event handler, passing e as PaintEventArgs.

private void RenderText6(PaintEventArgs e)
    TextFormatFlags flags = TextFormatFlags.Bottom | TextFormatFlags.EndEllipsis;
    TextRenderer.DrawText(e.Graphics, "This is some text that will be clipped at the end.", this.Font,
        new Rectangle(10, 10, 100, 50), SystemColors.ControlText, flags);

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0