Quote:
Originariamente inviato da Fabio7586
Due filtri nel senso di due texbox MARCA e MODELLO, ho provato a replicare il codice, ma il risultato è un datagridview vuoto!
|
Non è possibile...
Non so, per me è di una chiarezza totale. Prova semplicemente un progetto con questa Form :
Codice:
Public Class Form1
Private DS As New DataSet
Private BS As New BindingSource
Private filtroMarca As String = String.Empty
Private filtroMod As String = String.Empty
Private Sub cmd_fill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_fill.Click
DS.Tables.Clear()
DS.Tables.Add()
DS.Tables(0).Columns.Add("MARCA")
DS.Tables(0).Columns.Add("MODELLO")
DS.Tables(0).Rows.Add()
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MARCA") = "AAB"
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MODELLO") = "m1A"
DS.Tables(0).Rows.Add()
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MARCA") = "AAC"
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MODELLO") = "m2A"
DS.Tables(0).Rows.Add()
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MARCA") = "ABB"
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MODELLO") = "m1B"
DS.Tables(0).Rows.Add()
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MARCA") = "ABC"
DS.Tables(0).Rows(DS.Tables(0).Rows.Count - 1).Item("MODELLO") = "m2B"
BS.DataSource = DS.Tables(0)
DGV.DataSource = BS
End Sub
Private Sub txt_marca_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_marca.TextChanged, txt_modello.TextChanged
If txt_marca.TextLength > 0 Then
filtroMarca = "MARCA Like '" & txt_marca.Text & "*'"
Else
filtroMarca = "MARCA Like '*'"
End If
If txt_modello.TextLength > 0 Then
filtroMod = "MODELLO Like '" & txt_modello.Text & "*'"
Else
filtroMod = "MODELLO Like '*'"
End If
BS.Filter = filtroMarca & " AND " & filtroMod
End Sub
End Class
C'è già il doppio filtro su Marca / Modello.
Prova, e non dirmi che non funziona !