| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 976 人关注过本帖, 1 人收藏
标题:【分享】listview控件实例
只看楼主 加入收藏
coffecat1119
Rank: 2
等 级:论坛游民
帖 子:166
专家分:84
注 册:2008-6-19
结帖率:96.88%
收藏(1)
 问题点数:0 回复次数:9 
【分享】listview控件实例
listview控件实例.zip (30.83 KB)
搜索更多相关主题的帖子: listview 实例 控件 分享 
2010-04-30 23:30
coffecat1119
Rank: 2
等 级:论坛游民
帖 子:166
专家分:84
注 册:2008-6-19
收藏
得分:0 
晕倒,这例子还是好的嘛,怎么没人回应啊?
2010-05-08 22:29
柠檬悠悠
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-5-9
收藏
得分:0 
我刚好急需,谢谢啊,我看看哦!
2010-05-09 23:16
ll11202616
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-11-4
收藏
得分:0 
正在找,先看看啦,谢!
2010-11-04 16:13
qwerty448
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-2-8
收藏
得分:0 
谢谢你
2011-02-08 16:58
dasdaa
Rank: 1
等 级:新手上路
威 望:2
帖 子:40
专家分:0
注 册:2019-12-24
收藏
得分:0 
Sub 添加列表表头()
    Dim FimgX As ListImage
   
    Form1.ListView1.ColumnHeaders.Clear     '清除列标题
    Form1.ListView1.ListItems.Clear         '清除行数据
    Form1.ListView1.View = lvwReport        '视图模式为:报表视图
    Form1.ListView1.FullRowSelect = True    '整行选择
    Form1.ListView1.MultiSelect = True      '多行选择
    Form1.ListView1.GridLines = True        '显示网格
    Form1.ListView1.LabelEdit = lvwManual   '禁止编辑第一列

'    Form1.ListView1.ColumnHeaders.Add 1, , "id", 0
    Form1.ListView1.ColumnHeaders.Add 1, , "应付卡号", 2000
    Form1.ListView1.ColumnHeaders.Add 2, , "单位名称", 2000, lvwColumnCenter
    Form1.ListView1.ColumnHeaders.Add 3, , "终端号", 1800, lvwColumnCenter
   
    Set FimgX = Form1.ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\1×22.bmp"))
    Set FimgX = Form1.ImageList2.ListImages.Add(, , LoadPicture(App.Path & "\1×22.bmp"))

    '若要将 ImageList 控件和 ListView 控件一起使用,必须将 Icons 和 SmallIcons 属性与特定的 ImageList 控件关联。
    Form1.ListView1.Icons = Form1.ImageList1
    Form1.ListView1.SmallIcons = Form1.ImageList2
End Sub

[此贴子已经被作者于2020-12-4 13:28编辑过]

2020-12-04 13:23
dasdaa
Rank: 1
等 级:新手上路
威 望:2
帖 子:40
专家分:0
注 册:2019-12-24
收藏
得分:0 
'打印时以左上角为原点,向右和向下为正,反向为负
'字号为10号
Printer.FontSize=10
'打印机的横坐标
Printer.CurrentX = 0
'打印机的纵坐标
Printer.CurrentY = 0
'设定打印机是横向打印还是纵向打印,1:纵向;2:横向
Printer.Orientation = 1
'打印内容
Printer.Print ""
For i=1 To lvwPub.ListItems.Count
'打印ListView中每一行中每列的内容
'在打印每一列前先设定打印位置(坐标)
'打印机的横坐标
Printer.CurrentX = 0
'打印机的纵坐标
Printer.CurrentY = 0+i*5 '*5中的5为每行的高度
'ListView中每一行中第0列的内容
Printer.Print lvwPub.ListItems(i)
'打印机的横坐标
Printer.CurrentX = 10
'打印机的纵坐标
Printer.CurrentY = 0+i*5
'ListView中每一行中第1列的内容
Printer.Print lvwPub.ListItems(i).SubItems(1)
'打印机的横坐标
Printer.CurrentX = 20
'打印机的纵坐标
Printer.CurrentY = 0+i*5
'ListView中每一行中第2列的内容
Printer.Print lvwPub.ListItems(i).SubItems(2)
'打印机的横坐标
Printer.CurrentX = 30
'打印机的纵坐标
Printer.CurrentY = 0+i*5
'ListView中每一行中第3列的内容
Printer.Print lvwPub.ListItems(i).SubItems(3)
Next
'打印内容处理完毕,打印机打开始打印
Printer.EndDoc
2020-12-11 16:29
dasdaa
Rank: 1
等 级:新手上路
威 望:2
帖 子:40
专家分:0
注 册:2019-12-24
收藏
得分:0 
Dim i, j
  For i = 1 To ListView1.ListItems.Count
    Printer.Print ListView1.ListItems(i),
    For j = 1 To ListView1.ColumnHeaders.Count - 1
       Printer.Print ListView1.ListItems(i).SubItems(j),
    Next
    Printer.Print
  Next
  Printer.EndDoc
2020-12-11 16:29
dasdaa
Rank: 1
等 级:新手上路
威 望:2
帖 子:40
专家分:0
注 册:2019-12-24
收藏
得分:0 
Option Explicit

Dim XS As Long, YS As Long         '总体偏差
Dim XLEFT As Long, YTOP As Long     '页边距

     
Public Sub prnt(X As Single, y As Single, txt As String, Optional fnt As Long = 12)
    Printer.CurrentX = X + XS + XLEFT       '打印位置,页边距+总体偏差+位置
    Printer.CurrentY = y + YS + YTOP
    Printer.FontSize = fnt
    Printer.Print txt
End Sub

Private Sub Command1_Click()

    Printer.ScaleMode = vbTwips     '单位为缇,窗体控件坐标也为缇,必须统一

    Call prnt(Label1.Left, Label1.Top, Label1.Caption, 12)
    Call prnt(Label2.Left, Label2.Top, Label2.Caption, 12)
    Call prnt(Text1.Left, Text1.Top, Text1.Text, 12)
   
    Printer.EndDoc
End Sub

Private Sub Form_Load()

    '初始化
    XS = 0 * 567            '这二个数据,应该是保存到配置文件里的,每次打印前再临时读取
    YS = 0 * 567            '配置文件里,这二个值的单位是厘米
   
    XLEFT = 2.5 * 567
    YTOP = 2.5 * 567       '页边距,与上面这边相同,可以固定为一个值,这里是固定为 2.5厘米

End Sub
2020-12-11 20:30
雷厉风行2021
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2021-8-17
收藏
得分:0 
没来晚吧
2021-08-28 21:10
快速回复:【分享】listview控件实例
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043441 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved