我DataGridView從 MsAccess 檔案中獲得了一個帶有資料源的資料源,我通過多個快速過濾TextBox
如果為一個多列再添加一個 TextBox 過濾,則過濾無法正常作業,例如只顯示 5 個結果,它應該顯示 160 個結果
正常作業: IMG
Private Sub MPR_Filtrowanie(sender As Object, e As EventArgs) Handles FMPR_data.TextChanged, FMPR_kod.TextChanged, FMPR_opis.TextChanged,
FMPR_regal.TextChanged, FMPR_uwagi.TextChanged, FMPR_lotto.TextChanged, FMPR_akcja.TextChanged, FMPR_lotto_prod.TextChanged
MPruchyBindingSource.Filter = String.Format("Convert(data,'System.String') like '%{0}' and Convert(KodMP,'System.String') like '%{1}'
and Convert(opis_gal,'System.String') like '%{2}%' and Convert(regal,'System.String') like '%{3}' and Convert(uwagi,'System.String') like '%{4}%'
and Convert(lotto,'System.String') like '%{5}%' and Convert(akcja,'System.String') like '%{6}%'",
_FMPR_data.Text.ToString, FMPR_kod.Text.ToString, FMPR_opis.Text.ToString, FMPR_regal.Text.ToString,
_FMPR_uwagi.Text.ToString, FMPR_lotto.Text.ToString, FMPR_akcja.Text.ToString)
MPRdgv.DataSource = MPruchyBindingSource
End sub
無法正常作業(僅多一列):IMG
Private Sub MPR_Filtrowanie(sender As Object, e As EventArgs) Handles FMPR_data.TextChanged, FMPR_kod.TextChanged, FMPR_opis.TextChanged,
FMPR_regal.TextChanged, FMPR_uwagi.TextChanged, FMPR_lotto.TextChanged, FMPR_akcja.TextChanged, FMPR_lotto_prod.TextChanged
MPruchyBindingSource.Filter = String.Format("Convert(data,'System.String') like '%{0}' and Convert(KodMP,'System.String') like '%{1}'
and Convert(opis_gal,'System.String') like '%{2}%' and Convert(regal,'System.String') like '%{3}' and Convert(uwagi,'System.String') like '%{4}%'
and Convert(lotto,'System.String') like '%{5}%' and Convert(akcja,'System.String') like '%{6}%' and Convert(lotto_prod,'System.String') like '%{7}%'",
_FMPR_data.Text.ToString, FMPR_kod.Text.ToString, FMPR_opis.Text.ToString, FMPR_regal.Text.ToString,
_FMPR_uwagi.Text.ToString, FMPR_lotto.Text.ToString, FMPR_akcja.Text.ToString, FMPR_lotto_prod.Text.ToString)
MPRdgv.DataSource = MPruchyBindingSource
End sub
uj5u.com熱心網友回復:
我相當有信心,問題在于您的過濾器將僅匹配字串值而不匹配空值,因此您的過濾器將排除該列為空的行。在這種情況下,您可以更改:
Convert(lotto_prod,'System.String') like '%{7}%'
對此:
CONVERT(ISNULL(lotto_prod, ''),'System.String') LIKE '%{7}%'
我認為它應該作業。您可能需要對可能包含空值的其他列執行類似操作。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/515505.html
