2012-02-14 72 views

回答

1

你可以創建自己的文本,從文本框繼承和重載text屬性,並返回一個字符串修整,到處使用自定義的文本框...

喜歡的東西:

Public Class TrimmedTextBox 
    Inherits TextBox 

    Public Overloads Property Text As String 
     Get 
      Return CStr(GetValue(TextProperty)).Trim 
     End Get 
     Set(value As String) 
      SetValue(TextProperty, value) 
     End Set 
    End Property 

End Class 

或者你可以只是在從文本框中檢索文本時修剪文本,我假設您檢索它 - 或者爲什麼要有文本框?