Double clic dans une listbox

Hello la communauté,

Je ne parviens pas à formuler correctement les codes me permettant lorsque je clique sur une ligne dans la listbox, voir afficher toutes les données dans les champs situés au dessus.

Private Sub ListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

    TxtChercher.Text = ListBox.Column(0)
    If TxtChercher.Text = ListBox.Column(0) Then
    TxtNom = Me.Text = ListBox.Column(0)
    TxtPrenom = Me.Text = ListBox.Column(1)
    TxtNom = Me.Text = ListBox.Column(2)
    TxtNNational = Me.Text = ListBox.Column(3)
    TxtNMatricule = Me.Text = ListBox.Column(4)
    TxtEmail = Me.Text = ListBox.Column(5)
    TxtGSM.Text = Me.Text = ListBox.Column(6)
    TxtTelephone.Text = Me.Text = ListBox.Column(7)
    TxtNUrgence.Text = Me.Text = ListBox.Column(8)
    TxtEntreeEnFonction.Text = Me.Text = ListBox.Column(9)
    TxtNCompteBancaire.Text = Me.Text = ListBox.Column(10)
    TxtDateNaissance.Text = Me.Text = ListBox.Column(11)
    TxtLieuNaissance.Text = Me.Text = ListBox.Column(12)
    TxtPaysNaissance.Text = Me.Text = ListBox.Column(14)
    TxtAdresse.Text = Me.Text = ListBox.Column(15)
    TxtNumero.Text = Me.Text = ListBox.Column(16)
    TxtBoite.Text = Me.Text = ListBox.Column(17)
    TxtCodePostal.Text = Me.Text = ListBox.Column(18)
    TxtCommune.Text = Me.Text = ListBox.Column(19)
    CbxEtatCivil.Text = Me.Text = ListBox.Column(20)
    TxtNomConjoint.Text = Me.Text = ListBox.Column(21)
    TxtPrenomConjoint.Text = Me.Text = ListBox.Column(22)
    TxtDateNaissanceConjoint.Text = Me.Text = ListBox.Column(23)
    TxtLieuNaissanceConjoint.Text = Me.Text = ListBox.Column(24)
    TxtPaysNaissanceConjoint.Text = Me.Text = ListBox.Column(25)
    TxtGSMConjoint.Text = Me.Text = ListBox.Column(26)
    TxtCombienEnfants.Text = Me.Text = ListBox.Column(27)
    CbxEnfantACharge.Text = Me.Text = ListBox.Column(28)
    CbxNiveauDiplome.Text = Me.Text = ListBox.Column(29)
    CbxDenominationDiplome.Text = Me.Text = ListBox.Column(30)
    TxtDateDiplome.Text = Me.Text = ListBox.Column(31)
    TxtEcoleDiplome.Text = Me.Text = ListBox.Column(32)
    TxtDatePrestation.Text = Me.Text = ListBox.Column(33)

    End If

End Sub

Le plus frustrant, c'est que je ne parviens pas à trouver où se situe mon erreur... 🧐

Une âme charitable sera-t-elle prête à me filer un coup de main? 🙏

Bonjour Ralfy,

Une double égalité n'est pas possible sauf si on veut obtenir Vrai/Faux

TxtNom = Me.Text = ListBox.Column(0)

"Me.Text" ne veut rien dire, la syntaxe correcte est :

Me.TxtNom.Text = Me.ListBox.Column(0).Value

Rappel : vous avez normalement l'autocomplétion qui vous guide dans la saisie

image

A+

Merci beaucoup pour ta correction et ton conseil! 😀

Rechercher des sujets similaires à "double clic listbox"