如何获得系统目录并显示如listview控件中

han6688 2008-01-05 07:48:01
如题,系统目录显示在listview中,并可以像资源管理器一样操作
...全文
70 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhizlm 2008-01-05
  • 打赏
  • 举报
回复
Drive1.Drive=Dir1.Path;忽略驱动器改变

End Sub

双击目录列表框,输入以下代码:

Private Static Sub Dir1_Change()

File1.Path = Dir1.Path;关联文件列表框

If Right(Dir1.Path, 1) < > "\" Then

CurrentDir = Dir1.Path & "\"

Else

CurrentDir = Dir1.Path

End If;设置选定的目录名称

ListView1.ListItems.Clear;清除过期的列表项目

For Counter = 0 To File1.ListCount - 1

Fname = File1.List(Counter)

Set itmX = ListView1.ListItems.Add

(, , Fname);添加文件名

itmX.SubItems(1) = CStr(Counter + 1) + "/"

+ CStr(File1.ListCount)

itmX.SubItems(2) = CStr(FileLen(CurrentDir & Fname))

itmX.SmallIcon = 1

itmX.SubItems(3) = Format(FileDateTime(CurrentDir

& Fname), "HH:MM YYYY/MMMM/DD")

Next Counter;添加增强列表框的各个项目

Dir1.ToolTipText = "当前目录是:" & Dir1.Path;提示

End Sub

---- 通过以下代码取得鼠标单击增强列表框返回的项目名称:

Private Sub ListView1_ItemClick(ByVal Item As

MSComctlLib.ListItem)

allfname = Item;文件名

dname= CurrentDir& Item;完整的路径和文件名

sElectmain = ListView1.SelectedItem.Index;文件序号

End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧