StringFormat.Trimming 属性

定义

获取或设置此 StringFormat 对象的 StringTrimming 枚举。

public:
 property System::Drawing::StringTrimming Trimming { System::Drawing::StringTrimming get(); void set(System::Drawing::StringTrimming value); };
public System.Drawing.StringTrimming Trimming { get; set; }
member this.Trimming : System.Drawing.StringTrimming with get, set
Public Property Trimming As StringTrimming

属性值

StringTrimming 枚举,它指示当用此 StringFormat 对象绘制的文本超出布局矩形的边缘时被剪裁的方式。

示例

以下示例演示如何设置 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

适用于