-- 作者:ess110
-- 发布时间:2015/2/23 20:15:00
--
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1") lvw.StopRedraw() \'暂停绘制 lvw.Rows.Clear() \'清除原来的行 lvw.Images.Clear() \'清除原来的图片 lvw.View = ViewMode.Tile \'显示模式为 大图标 lvw.Images.LargeSize = New Size(55,75) \'定义大图标尺寸 lvw.TitleSize = New Size(195,90) Dim cls() As String = {"姓名","编号","部门","职务","性别","手机号码"} \'定义列名 For i As Integer = 0 To cls.Length - 1 \'增加列 Dim c As WinForm.ListViewColumn = lvw.Columns.Add() c.Name = cls(i) \'指定列名 Next
For Each dr As DataRow In DataTables("员工表").DataRows \'从数据表中提取数据 Dim Key As String = dr("相片") \'获取此员工的照片文件 lvw.Images.AddLargeImage(Key, Key) \'添加照片,直接用文件名作为图片键值 Dim vr As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 vr.ToolTipText = dr("备注") vr.ImageKey = Key \'设置图片键值 For Each cl As String In cls \'逐列取值 vr(cl) = cl &": "& dr(cl) Next Next lvw.ResumeRedraw() \'恢复绘制
|
-- 作者:有点甜
-- 发布时间:2015/2/23 20:21:00
--
以下是引用ess110在2015/2/23 20:17:00的发言: 之前的甜老师的代码,没有显示,字段“姓名,部门”等 如果要显示字段信息怎么写?
一样可以啊,代码没有问题
If Forms("员工信息").Opened AndAlso Tables("员工").Current IsNot Nothing Then Dim lvw As WinForm.ListView = Forms("员工信息").Controls("ListView1") lvw.StopRedraw() \'暂停绘制 lvw.Rows.Clear() \'清除原来的行 lvw.Images.Clear() \'清除原来的图片 lvw.View = ViewMode.Tile \'显示模式为 大图标 lvw.Images.LargeSize = New Size(65,75) \'定义大图标尺寸 lvw.TitleSize = New Size(150,90) Dim cls() As String = {"编号","姓名","部门","职务","性别"} \'定义列名 For i As Integer = 0 To cls.Length - 1 \'增加列 Dim c As WinForm.ListViewColumn = lvw.Columns.Add() c.Name = cls(i) \'指定列名 Next Dim dr As Row = Tables("员工").Current \'从数据表中提取数据 Dim Key As String = dr("照片") \'获取此员工的照片文件 lvw.Images.AddLargeImage(Key, Key) \'添加照片,直接用文件名作为图片键值 Dim vr As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 vr.ToolTipText = dr("备注") vr.ImageKey = Key \'设置图片键值 For Each cl As String In cls \'逐列取值 vr(cl) = dr(cl) Next lvw.ResumeRedraw() \'恢复绘制 End If
|