StringTrimming 枚举

定义

指定如何在不完全适合布局形状的字符串中修整字符。

public enum class StringTrimming
public enum StringTrimming
type StringTrimming = 
Public Enum StringTrimming
继承
StringTrimming

字段

Character 1

指定将文本修整成最接近的字符。

EllipsisCharacter 3

指定将文本修整成最接近的字符,并在被修整的行的末尾插入一个省略号。

EllipsisPath 5

中心从被修整的行移除并用省略号替换。 这种算法尽可能多地保留了行中的最后一个由斜杠分隔的段。

EllipsisWord 4

指定将文本修整成最接近的单词,并在被修整的行的末尾插入一个省略号。

None 0

指定不进行任何修整。

Word 2

指定将文本修整成最接近的单词。

示例

以下示例演示如何设置 Trimming 属性以及如何使用 StringTrimming 枚举。 此示例旨在与 Windows 窗体一起使用。 将此代码粘贴到窗体中,并在处理窗体的 Paint 事件时调用 ShowStringTrimming 方法,并将 e PaintEventArgs作为 传递。

private:
   void ShowStringTrimming( PaintEventArgs^ e )
   {
      StringFormat^ format1 = gcnew StringFormat;
      String^ quote = "Not everything that can be counted counts,"
      " and not everything that counts can be counted.";
      format1->Trimming = StringTrimming::EllipsisWord;
      e->Graphics->DrawString( quote, this->Font, Brushes::Black, RectangleF(10.0F,10.0F,90.0F,50.0F), format1 );
   }
private void ShowStringTrimming(PaintEventArgs e)
{

    StringFormat format1 = new StringFormat();
    string quote = "Not everything that can be counted counts," +
        " and not everything that counts can be counted.";
    format1.Trimming = StringTrimming.EllipsisWord;
    e.Graphics.DrawString(quote, this.Font, Brushes.Black, 
        new RectangleF(10.0F, 10.0F, 90.0F, 50.0F), format1);
}
Private Sub ShowStringTrimming(ByVal e As PaintEventArgs)

    Dim format1 As New StringFormat
    Dim quote As String = "Not everything that can be counted counts," & _
        " and not everything that counts can be counted."
    format1.Trimming = StringTrimming.EllipsisWord
    e.Graphics.DrawString(quote, Me.Font, Brushes.Black, _
        New RectangleF(10.0F, 10.0F, 90.0F, 50.0F), format1)
End Sub

适用于