StringFormat.Trimming 属性

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

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

语法

声明
Public Property Trimming As StringTrimming
用法
Dim instance As StringFormat
Dim value As StringTrimming

value = instance.Trimming

instance.Trimming = value
public StringTrimming Trimming { get; set; }
public:
property StringTrimming Trimming {
    StringTrimming get ();
    void set (StringTrimming value);
}
/** @property */
public StringTrimming get_Trimming ()

/** @property */
public void set_Trimming (StringTrimming value)
public function get Trimming () : StringTrimming

public function set Trimming (value : StringTrimming)

属性值

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

示例

下面的示例演示如何设置 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 CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、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

请参见

参考

StringFormat 类
StringFormat 成员
System.Drawing 命名空间