View Single Post
Old 31-07-2009, 13:59   #11
MarcoGG
Senior Member
 
L'Avatar di MarcoGG
 
Iscritto dal: Dec 2004
Messaggi: 3210
Quote:
Originariamente inviato da Fabio7586 Guarda i messaggi
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 !
MarcoGG è offline   Rispondi citando il messaggio o parte di esso