StringTrimming 枚举

定义

指定如何在不完全适合布局形状的字符串中修整字符。Specifies how to trim characters from a string that does not completely fit into a layout shape.

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

字段

Character 1

指定将文本修整成最接近的字符。Specifies that the text is trimmed to the nearest character.

EllipsisCharacter 3

指定将文本修整成最接近的字符,并在被修整的行的末尾插入一个省略号。Specifies that the text is trimmed to the nearest character, and an ellipsis is inserted at the end of a trimmed line.

EllipsisPath 5

中心从被修整的行移除并用省略号替换。The center is removed from trimmed lines and replaced by an ellipsis. 这种算法尽可能多地保留了行中的最后一个由斜杠分隔的段。The algorithm keeps as much of the last slash-delimited segment of the line as possible.

EllipsisWord 4

指定将文本修整成最接近的单词,并在被修整的行的末尾插入一个省略号。Specifies that text is trimmed to the nearest word, and an ellipsis is inserted at the end of a trimmed line.

None 0

指定不进行任何修整。Specifies no trimming.

Word 2

指定将文本修整成最接近的单词。Specifies that text is trimmed to the nearest word.

示例

下面的示例演示如何设置Trimming属性以及如何StringTrimming使用枚举。The following example shows how to set the Trimming property and how to use the StringTrimming enumeration. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with a Windows Form. 将此代码粘贴到窗体中, 并在处理窗体Paint事件时调用 ShowStringTrimming 方法, 并将 e 作为PaintEventArgs传递。Paste this code into a form and call the ShowStringTrimming method when handling the form's Paint event, passing e as 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

适用于