Controle listbox

Résolu
Bonjour,

j'ai deux listbox : listbox1 avec deux colonnes (A 76 : D 176 ), listbox2

quand je selectione une ligne de la listbox1 et je fai ajouter la ligne s'ajoute dans la listbox2 mais sur deux ligne

es ce possible d'afficher la ligne ajouter a la listbox2 sur une seule ligne

voila le bouton ajouter :

Private Sub AddButton_Click()

If ListBox1.ListIndex = -1 Then Exit Sub
ListBox2.AddItem ListBox1.Text
ListBox2.AddItem ListBox1.Value

End Sub
Configuration: Windows XP
Firefox 3.0.10

4 réponses

  1. Bonjour,

    Supprime soit ListBox2.AddItem ListBox1.Text, soit ListBox2.AddItem ListBox1.Value, les 2 font la même chose.

    ;o)
    1. bonjour merci pour ta réponse

      mais comment je peu faire pour que quand je sélectionne une ligne sur la listbox1,exemple (A 75: B75) , et je fais ajouter, toute la ligne s'affiche sur la listbox2

      j'ai deux colonne dans la listbox1, et les colonnes sources sont: Rowsource= Feuil1! A 75 : B 176

      les propriété de la listbox1 çà me donne çà :

      text = mon premier text de la colonne (A75)
      Value = mon premier text de la colonne 2 (B75)

      c pour ça j'ai mis ça

      Private Sub AddButton_Click()

      If ListBox1.ListIndex = -1 Then Exit Sub
      ListBox2.AddItem ListBox1.Text
      ListBox2.AddItem ListBox1.Value

      End Sub
      1. bonjour

        voila j'ai essai de beduier mon programme , ca marche pour la premiere fois mais pas la fois d'apres

        que pui-je faire svp

        merci de votre aide

        Private Sub AddButton_Click()
        Dim i As Integer

        If ListBox1.ListIndex = -1 Then Exit Sub
        For i = 0 To ListBox3.ListCount - 1
        If ListBox1.Value = ListBox3.List(i) Then
        Beep
        Exit Sub
        End If
        Next i

        ListBox2.AddItem ListBox1.Text

        i = _
        Application.WorksheetFunction.CountA(Range("A:A")) - 464

        If ListBox2 = ListBox1.Text Then
        Cells(i, 3) = True
        End If
        ListBox3.AddItem ListBox1.Value
        If ListBox3 = ListBox1.Value Then
        Cells(i, 3) = True
        End If
        End Sub
        bonne journer
        1. bonjour
          c bon jai trouver pour afficher la ligne entiere (premiere question)

          au lieu d'utiliser 2 listbox , jai utiliser 3 listbox : voir l'explication

          bouton ajouter

          Private Sub AddButton_Click()
          Dim i As Integer

          If ListBox1.ListIndex = -1 Then Exit Sub
          For i = 0 To ListBox3.ListCount - 1
          If ListBox1.Value = ListBox3.List(i) Then
          Beep
          Exit Sub
          End If
          Next i

          ListBox2.AddItem ListBox1.Text
          ListBox3.AddItem ListBox1.Value

          End Sub