StringTrimming 枚举

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

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Enumeration StringTrimming
用法
Dim instance As StringTrimming
public enum StringTrimming
public enum class StringTrimming
public enum StringTrimming
public enum StringTrimming

成员

  成员名称 说明
Character 指定将文本修整成最接近的字符。 
EllipsisCharacter 指定将文本修整成最接近的字符,并在被修整的行的末尾插入一个省略号。 
EllipsisPath 中心从被修整的行移除并用省略号替换。这种算法尽可能多地保留了行中的最后一个由斜杠分隔的段。 
EllipsisWord 指定将文本修整成最接近的单词,并在被修整的行的末尾插入一个省略号。 
None 指定不进行任何修整。 
Word 指定将文本修整成最接近的单词。 

示例

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

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
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:
   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.set_Trimming(StringTrimming.EllipsisWord);
    e.get_Graphics().DrawString(quote, this.get_Font(), 
        Brushes.get_Black(), new RectangleF(10, 10, 90, 50), format1);
} //ShowStringTrimming

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

System.Drawing 命名空间