参考代码
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.StopRedraw() '停止绘制
lvw.Groups.Clear() '清除原来的分组
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
Dim filter As String = "日期 = #" & Date.Today & "#"
lvw.View = ViewMode.Details '显示模式为详细信息
Dim cls() As String = {"状态","时间段","病人姓名","预约项目"} '定义列名
Dim wds() As Integer = {100,100,150,80,80} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Name = cls(i) '指定列名
c.Text = cls(i) '指定标题,这里标题和列名相同
c.Width = wds(i) '指定列宽
Next
For Each zh As String In DataTables("预约表").GetValues("开始时", filter) '增加分组
Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
grp.Name = zh
Select Case zh
Case 9
grp.Text = "9:00-10:00"
Case 10
grp.Text = "10:00-11:00"
Case 11
grp.Text = "11:00-12:00"
Case Else
grp.Text = zh
End Select
Next
For Each dr As DataRow In DataTables("预约表").Select(filter)
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
r.Group = dr("开始时")
For Each cl As String In cls '逐列取值
r(cl) = dr(cl)
Next
r.CellUseRowStyle = False
If dr("状态") = "已约" Then '用蓝底白字整行显示东正教国家
r.Cells(0).BackColor = Color.Gray
r.Cells(0).ForeColor = Color.White
Else If dr("状态") = "取消" Then
r.Cells(0).BackColor = Color.Brown
r.Cells(0).ForeColor = Color.White
Else If dr("状态") = "到达" Then
r.Cells(0).BackColor = Color.DarkViolet
r.Cells(0).ForeColor = Color.White
Else If dr("状态") = "过期" Then
r.Cells(0).BackColor = Color.Gray
r.Cells(0).ForeColor = Color.White
Else
End If
Next
lvw.ResumeRedraw() '恢复绘制