共用方式為


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 Form 搭配使用。 將此程式代碼貼到表單中,並在處理表單的事件時呼叫 ShowStringTrimming 方法,並將 e 傳遞為 PaintEventArgsPaint

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

適用於