此主题相关图片如下:listview512.png
代码如下, 如何更改呢?
Dim lvw As WinForm.ListView = Forms("FTP生产图纸管理器").Controls("ListView1")
'lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear
lvw.Images.Clear
lvw.Images.LargeSize = new size(32,32)
Dim ics As String() = {"swf","accdb","mdb","psd","png","xls","xlsx","bmp","rar","jpg","doc","docx","zip","pdf","txt","ppt","exe","dwg","other"} '定义扩展名数组
Dim kzms As String ="swf accdb mdb psd png xls xlsx bmp rar jpg doc docx zip pdf txt ppt dwg exe" '定义已知扩展名的文本串
For Each ic As String In ics
lvw.Images.AddImage(ic,ic & ".png",ic & ".png") '向listview里添加图标
Next
'==============================以上是设置listview的代码============================
'==============================以下是生成listview的代码============================
Dim sts As List(of String) = ftp.GetFileList(fp)
If sts.Count > 0 Then '若有文件
For Each st As String In sts
Dim r As WinForm.ListViewRow = lvw.Rows.Add '增加一行
Dim Dot As Integer = st.LastIndexOf(".") '定义.的位置
Dim kzm As String = st.SubString(Dot + 1) '获取扩展名
r.text = st
If kzms.Contains(kzm) = True Then '若为已知扩展名
r.ImageKey = kzm '指定行的图标键值
Else
r.ImageKey = "other"
End If
Next
End If