StringTrimming 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定如何從不符合配置形狀的字串修剪字元。
public enum class StringTrimming
public enum StringTrimming
type StringTrimming =
Public Enum StringTrimming
- 繼承
欄位
Character | 1 | 指定將文字修剪為最接近的字元。 |
EllipsisCharacter | 3 | 指定文字修剪為最接近的字元,並且在修剪行的末端插入省略號。 |
EllipsisPath | 5 | 從修剪行移除中心點,並以省略號來取代。 演算法會盡可能保留文字行最後的斜線分隔區段。 |
EllipsisWord | 4 | 指定文字修剪為最接近的字,並且在修剪行的末端插入省略號。 |
None | 0 | 不指定修剪。 |
Word | 2 | 指定將文字修剪為最接近的字。 |
範例
下列範例示範如何設定 Trimming 屬性,以及如何使用 StringTrimming 列舉。 此範例的設計目的是要與 Windows Form 搭配使用。 將此程式代碼貼到表單中,並在處理表單的 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