Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacements for DirListBox and/or FileListBox from Microsoft.VisualBasic.Compatibility

I have a VB6 application that has been migrated to VB.net, and am trying to upgrade the framework version to 4.5 -- which complained that everything in Microsoft.VisualBasic.Compatibility dll was obsolete. I was able to replace everything except the FileListBox and DirListBox fairly easily -- tedious but I didn't have to create any new controls.

Is there a close replacement for these controls? Does anyone know if they have been opened sourced with the rest of the framework?

like image 342
jmoreno Avatar asked Oct 18 '25 00:10

jmoreno


1 Answers

You can use simple ListBox control and use My.Computer.FileSystem to make them as old DriveListBox, DirectoryListBox and FileListBox. You can use something like following

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    lstDriveList.DataSource = My.Computer.FileSystem.Drives
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstDriveList.SelectedIndexChanged
    lstDirectoryList.DataSource = My.Computer.FileSystem.GetDirectories(lstDriveList.SelectedValue.ToString())
End Sub


Private Sub lstDirectoryList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstDirectoryList.SelectedIndexChanged
    lstFileList.DataSource = My.Computer.FileSystem.GetFiles(lstDirectoryList.SelectedValue.ToString())
End Sub

All the lst are just normal ListBoxes you can also use ListView control, similar way.

like image 80
KMan Avatar answered Oct 19 '25 12:10

KMan