StringFormatFlags 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.DrawingAssembly: System.Drawing (in System.Drawing.dll)
| Member name | Description | |
|---|---|---|
| DirectionRightToLeft | Text is displayed from right to left. | |
| DirectionVertical | Text is vertically aligned. | |
| FitBlackBox | Parts of characters are allowed to overhang the string's layout rectangle. By default, characters are repositioned to avoid any overhang. | |
| DisplayFormatControl | Control characters such as the left-to-right mark are shown in the output with a representative glyph. | |
| NoFontFallback | Fallback to alternate fonts for characters not supported in the requested font is disabled. Any missing characters are displayed with the fonts missing glyph, usually an open square. | |
| MeasureTrailingSpaces | Includes the trailing space at the end of each line. By default the boundary rectangle returned by the MeasureString method excludes the space at the end of each line. Set this flag to include that space in measurement. | |
![]() | NoWrap | Text wrapping between lines when formatting within a rectangle is disabled. This flag is implied when a point is passed instead of a rectangle, or when the specified rectangle has a zero line length. |
| LineLimit | Only entire lines are laid out in the formatting rectangle. By default layout continues until the end of the text, or until no more lines are visible as a result of clipping, whichever comes first. Note that the default settings allow the last line to be partially obscured by a formatting rectangle that is not a whole multiple of the line height. To ensure that only whole lines are seen, specify this value and be careful to provide a formatting rectangle at least as tall as the height of one line. | |
![]() | NoClip | Overhanging parts of glyphs, and unwrapped text reaching outside the formatting rectangle are allowed to show. By default all text and glyph parts reaching outside the formatting rectangle are clipped. |
StringFormatFlags is used by the StringFormat class.
Note: |
|---|
The FitBlackBox field was misnamed and its behavior is similar to the NoFitBlackBox field in the original GDI+ implementation. |
The following code example demonstrates the following members:
StringFormatFlags
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.
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs) ' Construct a new Rectangle. Dim displayRectangle _ As New Rectangle(New Point(40, 40), New Size(80, 80)) ' Construct two new StringFormat objects Dim format1 As New StringFormat(StringFormatFlags.NoClip) Dim format2 As New StringFormat(format1) ' Set the LineAlignment and Alignment properties for ' both StringFormat objects to different values. format1.LineAlignment = StringAlignment.Near format1.Alignment = StringAlignment.Center format2.LineAlignment = StringAlignment.Center format2.Alignment = StringAlignment.Far ' Draw the bounding rectangle and a string for each ' StringFormat object. e.Graphics.DrawRectangle(Pens.Black, displayRectangle) e.Graphics.DrawString("Showing Format1", Me.Font, Brushes.Red, _ RectangleF.op_Implicit(displayRectangle), format1) e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _ RectangleF.op_Implicit(displayRectangle), format2) End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
