StringFormatFlags 枚举  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定文本字符串的显示和布局信息。
此枚举支持其成员值的按位组合。
public enum class StringFormatFlags[System.Flags]
public enum StringFormatFlags[<System.Flags>]
type StringFormatFlags = Public Enum StringFormatFlags- 继承
- 属性
字段
| 名称 | 值 | 说明 | 
|---|---|---|
| DirectionRightToLeft | 1 | 按从右向左的顺序显示文本。 | 
| DirectionVertical | 2 | 垂直对齐文本。 | 
| DisplayFormatControl | 32 | 控制字符(如从左到右标记)随具有代表性的字形一起显示在输出中。 | 
| FitBlackBox | 4 | 允许部分字符延伸该字符串的布局矩形。 默认情况下,将重新定位字符以避免任何延伸。 | 
| LineLimit | 8192 | 在格式化的矩形中只布置整行。 默认情况下,这种布置要继续到文本的结尾为止,或者到由于剪裁而不再有可见的行为止,看哪种情况先发生。 注意,此默认设置允许不是行高整数倍的格式化矩形将最后一行的部分遮住。 若要确保看到的都是整行,请指定此值,并注意提供格式化矩形,使其高度至少为一个行高。 | 
| MeasureTrailingSpaces | 2048 | 包括每一行结尾处的尾随空格。 在默认情况下,MeasureString 方法返回的边界矩形都将排除每一行结尾处的空格。 设置此标记以便在测定时将空格包括进去。 | 
| NoClip | 16384 | 允许显示字形符号的伸出部分和延伸到矩形外的未换行文本。 默认情况下,延伸到矩形外侧的所有文本和字形部分都会被剪裁掉。 | 
| NoFontFallback | 1024 | 对于请求的字体中不支持的字符,禁用回退到可选字体。 丢失的任何字符都用丢失字形的字体显示,通常为一个空的方块。 | 
| NoWrap | 4096 | 在矩形内设置格式时,禁用自动换行功能。 当传递的是点而不是矩形时,或者指定矩形的行长度为零时,已隐含此标记。 | 
示例
下面的代码示例演示了以下成员:
此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中, ShowLineAndAlignment 并在处理窗体 Paint 的事件时调用 方法,作为 ePaintEventArgs传递。
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
注解
StringFormatFlags 由 StringFormat 类使用。
注意
FitBlackBox 字段的名称错误,其行为类似于 NoFitBlackBox 原始 GDI+ 实现中的字段。