cs_defluc
Messages postés23Date d'inscriptionmardi 24 septembre 2002StatutMembreDernière intervention22 février 2008
-
6 mars 2004 à 12:04
cs_defluc
Messages postés23Date d'inscriptionmardi 24 septembre 2002StatutMembreDernière intervention22 février 2008
-
18 juin 2004 à 15:27
Je voudrais renseigner dans une TextBox le chemin complet d'un Item cliqué dans une Dirlistbox.
Comme la sélection ne se fait que par un double clic, Dirlistbox.Path donne la sélection active et non celle du simple clic.
Quelqu'un pourrait-il me proposer une solution ?
cs_defluc
Messages postés23Date d'inscriptionmardi 24 septembre 2002StatutMembreDernière intervention22 février 2008 18 juin 2004 à 15:27
Voilà ma solution.
Private Sub DirListBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox.Click
DirSel()
End Sub
A la sélection d'un dossier dans la DirListBox, l'évènement On Click appelle la procédure DirSel ci-après qui affiche le chemin complet (Drive, Dosssier, sous-dossier,... dans une TextBox, ici, "PethTextBox.
Private Sub DirSel()
Dim j, SubDirLevel As Short
Dim FileName, TmpStr As String
Dim PathSubPath() As String
Dim NbrSubDir As Integer
PathSubPath = Split(DirListBox.Path & "", "")
SubDirLevel = UBound(PathSubPath)
If PathSubPath(0) & "" = DirListBox.SelectedItem Then
PathTextBox.Text = DirListBox.SelectedItem
Exit Sub
End If
If DirListBox.SelectedIndex = 1 Then
PathTextBox.Text = PathSubPath(0) & "" & DirListBox.SelectedItem & ""
Exit Sub
End If
PathTextBox.Text = ""
For j = 0 To SubDirLevel
TmpStr = PathSubPath(j)
If TmpStr <> "" Then PathTextBox.Text = PathTextBox.Text & TmpStr & "" If SubDirLevel 1 Or TmpStr DirListBox.SelectedItem Then
Exit For
End If
Next
If SubDirLevel < j Then PathTextBox.Text = PathTextBox.Text & DirListBox.SelectedItem & ""
End Sub