Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim fnt As New Font("微软雅黑",9)
lvw.font = fnt
lvw.StopRedraw() '暂停绘制
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.GridLines = True '显示网格线
Dim cls() As String = {"销售日期","销售单号","会员卡号","姓名","会员等级","积分否","积分已送","赠送积分","销售金额"} '定义列名
Dim wds() As String = {100,100,100,50,50,40,40,30,30} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = cls(i) '指定列标题
c.Name = cls(i) '指定列名
c.Width = wds(i) '指定列宽
Next
If dt.DataRows.Count > 0 Then
For Each dr As DataRow In datables("xxx").DataRows
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
For Each cl As String In cls '逐列取值
r(cl) = dr(cl)
Next
Next
lvw.ResumeRedraw()
这样没有问题可以生成
但是这样写 就生成不了
forms("xxx").show
if forms("xxx").opened then
Dim lvw As WinForm.ListView = forms("xxx").Controls("ListView1")
Dim fnt As New Font("微软雅黑",9)
lvw.font = fnt
lvw.StopRedraw() '暂停绘制
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.GridLines = True '显示网格线
Dim cls() As String = {"销售日期","销售单号","会员卡号","姓名","会员等级","积分否","积分已送","赠送积分","销售金额"} '定义列名
Dim wds() As String = {100,100,100,50,50,40,40,30,30} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = cls(i) '指定列标题
c.Name = cls(i) '指定列名
c.Width = wds(i) '指定列宽
Next
If dt.DataRows.Count > 0 Then
For Each dr As DataRow In datables("xxx").DataRows
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
For Each cl As String In cls '逐列取值
r(cl) = dr(cl)
Next
Next
lvw.ResumeRedraw()
end if