Remplir Listview avec plusieurs combobox

Bonjour à toutes et tous,

je souhaite pouvoir remplir un listview avec plusieurs combobox. Je m'explique.

j'ai 4 ensembles, et dans chacun de ces ensembles il y a des pièces. j'ai donc mis ça dans des combobox.

je souhaite pouvoir créer une liste compilée à partir du choix qui aura été fait dans chacune de ces combobox.

je fais un choix dans ma première combobox et cela rempli ma listview,

je fais un choix dans ma deuxième combobox et cela vient s'aditionner à la listview.

j'ai mis un fichier joint pour montrer où j'en suis.

j'espère que vous allez pouvoir m'aider.

Bonjour,

Testes si ça te convient :

Sub Remplir()

    Dim Lig As Long
    Dim J As Long
    Dim K As Long
    Dim C As Long

    With Me.ListView1

        .ListItems.Clear
        J = 1

        If ComboBox1.Text <> "" Then

            For Lig = 1 To UBound(Tbl)

                If Tbl(Lig, 2) = ComboBox1.Text Then

                    .ListItems.Add , , Tbl(Lig, 1)
                    For K = 2 To Ncol: .ListItems(J).ListSubItems.Add , , Tbl(Lig, K): Next K
                    J = J + 1
                    C = C + 1

                End If

            Next Lig

            Me.Label5.Caption = C: C = 0

        End If

        If ComboBox2.Text <> "" Then

            For Lig = 1 To UBound(Tbl)

                If Tbl(Lig, 2) = ComboBox2.Text Then

                    .ListItems.Add , , Tbl(Lig, 1)
                    For K = 2 To Ncol: .ListItems(J).ListSubItems.Add , , Tbl(Lig, K): Next K
                    J = J + 1
                    C = C + 1

                End If
            Next Lig

            Me.Label6.Caption = C: C = 0

        End If

        If ComboBox3.Text <> "" Then

            For Lig = 1 To UBound(Tbl)

                If Tbl(Lig, 2) = ComboBox3.Text Then

                    .ListItems.Add , , Tbl(Lig, 1)
                    For K = 2 To Ncol: .ListItems(J).ListSubItems.Add , , Tbl(Lig, K): Next K
                    J = J + 1
                    C = C + 1

                End If
            Next Lig

            Me.Label7.Caption = C: C = 0

        End If

        If ComboBox4.Text <> "" Then

            For Lig = 1 To UBound(Tbl)

                If Tbl(Lig, 2) = ComboBox4.Text Then

                    .ListItems.Add , , Tbl(Lig, 1)
                    For K = 2 To Ncol: .ListItems(J).ListSubItems.Add , , Tbl(Lig, K): Next K
                    J = J + 1
                    C = C + 1

                End If
            Next Lig

            Me.Label8.Caption = C: C = 0

        End If

    End With

End Sub

Private Sub ComboBox1_Click()

    Remplir

End Sub

Private Sub ComboBox2_Click()

    Remplir

End Sub

Private Sub ComboBox3_Click()

    Remplir

End Sub

Private Sub ComboBox4_Click()

    Remplir

End Sub

Merci beaucoup de ton aide. Cela fonctionne très bien.

Rechercher des sujets similaires à "remplir listview combobox"