【问题标题】:Replacements for DirListBox and/or FileListBox from Microsoft.VisualBasic.Compatibility从 Microsoft.VisualBasic.Compatibility 替换 DirListBox 和/或 FileListBox
【发布时间】:2015-09-11 09:41:06
【问题描述】:

我有一个已迁移到 VB.net 的 VB6 应用程序,并且正在尝试将框架版本升级到 4.5 - 它抱怨 Microsoft.VisualBasic.Compatibility dll 中的所有内容都已过时。除了 FileListBox 和 DirListBox 之外,我可以相当轻松地替换所有东西——虽然乏味,但我不必创建任何新控件。

这些控件是否有近似替代品?有谁知道它们是否已与框架的其余部分一起开源?

【问题讨论】:

    标签: .net .net-4.5 vb6-migration


    【解决方案1】:

    您可以使用简单的 ListBox 控件并使用 My.Computer.FileSystem 将它们制作为旧的 DriveListBox、DirectoryListBox 和 FileListBox。您可以使用类似以下的内容

    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
    

    所有lst只是普通的ListBoxes,你也可以使用ListView控件,类似的方式。

    【讨论】:

    • 请注意,这不会列出/输入子目录。
    【解决方案2】:

    不幸的是,您将不得不自己动手(就像@kman 踢了您一样)。

    这里讨论了一些替代方案:https://social.msdn.microsoft.com/Forums/en-US/b2d13c9a-e320-4f36-981e-e4c1999d7694/vbnet-equivalent-of-vb6-code-which-are-obsolete?forum=vbinterop

    有人建议回到 Framework 3.5(如果你没有使用 4.5 的特性)来争取一些时间来编写新的控件

    【讨论】:

      猜你喜欢
      • 2011-07-14
      • 1970-01-01
      • 1970-01-01
      • 2016-03-27
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      相关资源
      最近更新 更多