combobox bound cant trim whitespace?

cwfontan

Active member
Joined
Jan 9, 2009
Messages
35
Programming Experience
1-3
Returns a list of customers with whitespace on the end.. very annoying :confused:

what can i do to trim in code behind?
Also if I bind using the databinding on smart tag is there a way to trim?


VB.NET:
        cbo_customer.DataSource = M8CustomersBindingSource
        cbo_customer.DisplayMember = BA_TruckingDataSet.M8_Customers.CustomerNameColumn.ToString.Trim
        cbo_customer.ValueMember = BA_TruckingDataSet.M8_Customers.CustIDColumn.ToString.Trim

thanks
 
You can for example set FormattingEnabled and handle Format event like this:
VB.NET:
If e.DesiredType Is GetType(String) Then
    e.Value = e.Value.ToString.Trim
End If
Strings doesn't have any custom format specifiers so you can't set any FormatString to enable trim.
 
Found out what it was.. wow.. some how all the spaces where char(160) instead of char(32)...

did a replace and trim workss..
 
Back
Top