Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim tb As Table = e.Form.Controls("Table1").Table
Dim icon As Icon
lvw.StopRedraw
lvw.Groups.Clear() '清除原来的分组
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.LargeIcon '用大图标模式
lvw.Images.LargeSize = New Size(48,48)
lvw.AutoResizeColumns()
'lvw.View = ViewMode.Details '设置显示模式为详细内容
'lvw.GridLines = True '显示网格线
If FileSys.DirectoryExists(ProjectPath & e.Form.name)
FileSys.DeleteDirectory(ProjectPath & e.Form.Name,2,2)
End If
FileSys.CreateDirectory(ProjectPath & e.Form.Name)
'////////////////////设置图片//////////////////
For Each r As Row In tb.Rows
Select Case r("类型")
Case "文件夹"
lvw.Images.AddLargeImage("文件夹",ProjectPath & "Images\1064.ico")
Case ".jpg"
'lvw.Images.AddLargeImage(r("文件全名"),r("文件全名"))
lvw.Images.AddLargeImage(r("_identify"),r("文件全名"))
Case Else
Dim nm As String = r("类型").TrimStart(".")
If FileSys.FileExists(ProjectPath & e.Form.name & "\" & nm & ".png") Then
lvw.Images.AddLargeImage(r("类型"),ProjectPath & e.Form.name & "\" & nm & ".png")
Else
icon = System.Drawing.Icon.ExtractAssociatedIcon(r("文件全名"))
icon.ToBitmap().Save(ProjectPath & e.Form.name & "\" & nm & ".png")
lvw.Images.AddLargeImage(r("类型"),ProjectPath & e.Form.name & "\" & nm & ".png")
End If
End Select
Next
Dim Multi As String = tb.DataTable.GetComboListString("类型")
Dim Values() As String
Values = Multi.split("|")
For Index As Integer = 0 To Values.Length - 1
Dim lvwg As WinForm.ListViewGroup = lvw.Groups.Add()
lvwg.Name= Values(Index)
lvwg.text =Values(Index).TrimStart(".")
Dim filter As String = iif(tb.filter > "", tb.filter , "1=1")
For Each dr As DataRow In tb.DataTable.Select( "(" & Filter & ") And 类型 = '" & Values(Index) & "'" )
Dim it As WinForm.ListViewRow =lvw.Rows.Add()
it.Text = dr("名称")
it.name = dr("文件全名")
it.Group = Values(Index) '归纳分组
Select Case dr("类型")
Case "文件夹"
it.ImageKey = "文件夹"
Case ".jpg"
it.ImageKey = dr("_identify") ' dr("文件全名")
Case Else
it.ImageKey = dr("类型")
End Select
it.Font = New Font("Noto Sans S Chinese Regular",8, FontStyle.regular)
'it.ToolTipText = dr("功能概述")
Next
Next
lvw.ResumeRedraw