1、DirListBox和FileListBox
如何才能让每次程序启动时,FileListBox不显示东西。(每次启动都显示当前路径下的文件)
2、选择一个路径,在FileListBox里自动选中第一个文件(颜色为选中的状态)。

解决方案 »

  1.   

    Option ExplicitPrivate Sub Form_Load()
        File1.Path = "c:\windows"
        File1.ListIndex = 0
    End Sub
      

  2.   

    Private Sub Dir1_Change()
        File1.Pattern = "*.*"
        File1.Path = Dir1.Path
        
        If File1.ListCount > 0 Then
        ' 如果列表中有文件就选择第一个
            File1.ListIndex = 0
        End If
    End SubPrivate Sub Form_Load()
        ' 这里使用一个技巧. 不是定是用这个值。用一个几乎不可能存在的文件名字就行了
        File1.Pattern = "*.gg.g.g.gg.ggg"
    End Sub
      

  3.   

    Private Sub File1_PathChange()
    If File1.ListCount > 0 Then File1.ListIndex = 0
    If File1.Pattern <> "*.*" Then File1.Pattern = "*.*"
    End SubPrivate Sub Form_Load()
        File1.Pattern = "*.asdf" '现实扩展名为asdf 其实不存在
    End Sub