Option Strict On Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fichier As String FileListBox1.Items.Clear() 'on nettoie la FileListBox Dim a As New FolderBrowserDialog If a.ShowDialog = Windows.Forms.DialogResult.OK Then fichier = "" & a.SelectedPath & "" FileListBox1.Pattern = "*.*" FileListBox1.Path = fichier End If 'on affiche les données dans FileListBox For i = 0 To FileListBox1.Items.Count - 1 FileListBox1.Items.Add(FileListBox1.Items(i)) Next i End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub FileListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.DoubleClick Process.Start(fichier & "" & FileListBox1.Text) 'chemin du fichier End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load FileListBox1.Items.Clear() 'on nettoie la FileListBox Dim a As New FolderBrowserDialog '1er dossier If a.ShowDialog = Windows.Forms.DialogResult.OK Then fichier = "" & a.SelectedPath & "" FileListBox1.Pattern = "*.*" FileListBox1.Path = fichier Else MessageBox.Show("Opération annulée par l'utilisateur!", "Chemin dossier", MessageBoxButtons.OK, MessageBoxIcon.Information) Exit Sub End If 'on affiche les données dans FileListBox For i = 0 To FileListBox1.Items.Count - 1 FileListBox1.Items.Add(FileListBox1.Items(i)) Next i End Sub
FileListBox1.Items.Clear() 'on nettoie la FileListBox