StringFormatFlags 列舉

定義

指定文字字串的顯示和配置資訊。Specifies the display and layout information for text strings.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class StringFormatFlags
[System.Flags]
public enum StringFormatFlags
type StringFormatFlags = 
Public Enum StringFormatFlags
繼承
StringFormatFlags
屬性

欄位

DirectionRightToLeft 1

文字會由右至左顯示。Text is displayed from right to left.

DirectionVertical 2

文字會垂直對齊。Text is vertically aligned.

DisplayFormatControl 32

控制字元 (例如由右至左標記) 會以代表圖像 (Glyph) 顯示於輸出中。Control characters such as the left-to-right mark are shown in the output with a representative glyph.

FitBlackBox 4

允許部分字元突出字串的配置矩形。Parts of characters are allowed to overhang the string's layout rectangle. 根據預設,會重新調整字元位置以避免任何突出部分。By default, characters are repositioned to avoid any overhang.

LineLimit 8192

只有整行會配置在格式化矩形中。Only entire lines are laid out in the formatting rectangle. 根據預設值,配置會持續到文字結束為止,或者持續到因為裁剪 (Clipping) 而讓文字不再顯示為止 (無論何者先發生)。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.

MeasureTrailingSpaces 2048

包含每行結尾處的後端空白字元。Includes the trailing space at the end of each line. 根據預設值,由 MeasureString 方法傳回的邊界矩形會排除每行末端的空白。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.

NoClip 16384

允許顯示圖像的突出部分和超出格式化矩形外部的未換行文字。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.

NoFontFallback 1024

停用將要求字型中不支援的字元字型回溯為替代字型的功能。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.

NoWrap 4096

停用在矩形中進行格式化時的行間文字換行功能。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.

範例

下列程式碼範例將示範下列成員:The following code example demonstrates the following members:

這個範例是設計來與 Windows Forms 搭配使用。This example is designed to be used with Windows Forms. 將程式碼貼入表單, 並在ShowLineAndAlignment處理表單的Paint事件時呼叫方法, e傳遞PaintEventArgs為。Paste the code into a form and call the ShowLineAndAlignment method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void ShowLineAndAlignment( PaintEventArgs^ e )
   {
      // Construct a new Rectangle .
      Rectangle displayRectangle = Rectangle(Point(40,40),System::Drawing::Size( 80, 80 ));
      
      // Construct 2 new StringFormat objects
      StringFormat^ format1 = gcnew StringFormat( StringFormatFlags::NoClip );
      StringFormat^ format2 = gcnew 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", this->Font, Brushes::Red, displayRectangle, format1 );
      e->Graphics->DrawString( "Showing Format2", this->Font, Brushes::Red, displayRectangle, format2 );
   }
private void ShowLineAndAlignment(PaintEventArgs e)
{

    // Construct a new Rectangle .
    Rectangle  displayRectangle = 
        new Rectangle (new Point(40, 40), new Size (80, 80));

    // Construct 2 new StringFormat objects
    StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
    StringFormat format2 = 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", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format1);
    e.Graphics.DrawString("Showing Format2", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format2);
}
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

備註

StringFormatFlagsStringFormat類別使用。StringFormatFlags is used by the StringFormat class.

注意

FitBlackBox 欄位是 misnamed, 其行為類似于原始 gdi + NoFitBlackBox實中的欄位。The FitBlackBox field was misnamed and its behavior is similar to the NoFitBlackBox field in the original GDI+ implementation.

適用於