2014-02-18 77 views
0

我使用visual.net 2012 - 我使用此代碼來過濾textbox的bindingsource - 一切工作正常,但是當我刪除文本中的文本bindingsource只顯示有價值的行.. 這是我的代碼:vb。 net bindingsource filter

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged 
    SalesBindingSource.Filter = "[REF] LIKE '%" & TextBox2.Text & "%'" 
End Sub 

我如何使它顯示所有當我從文本刪除文本

回答

1

您需要刪除的過濾器,如果沒有文字:

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged 
    SalesBindingSource.Filter = If((TextBox2.Text.Length > 0), "[REF] LIKE '%" & TextBox2.Text & "%'", "") 
End Sub