|
楼主 |
发表于 2014-3-1 20:45
|
显示全部楼层
窗体初始化代码- Private Sub UserForm_Initialize()
- With Toolbar1
- .Style = tbrFlat '设置工具栏样式
- .ImageList = ImageList1 '绑定图标来源到listview1
- .Buttons.Add Style:=3 '添加一个占位按钮
- .Buttons.Add Style:=3
- .Buttons.Add Caption:="增加单据", Style:=0, Image:=1 '添加按钮并设置其标题,样式,图标
- .Buttons.Add Caption:="保存单据", Style:=0, Image:=2
- .Buttons.Add Caption:="查询单据", Style:=5, Image:=3
- .Buttons.Add Caption:="打印单据", Style:=0, Image:=4
- .Buttons.Add Caption:="撤消", Style:=0, Image:=5
- .Buttons.Add Style:=0
- .Buttons(8).Enabled = False
- .Buttons.Add Caption:="退出", Style:=0, Image:=6
- .Buttons.Add Style:=3
- .Buttons.Add Style:=3
- End With
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- arr = Sheet1.UsedRange
- With ListView1 'Listview1初始化
- .ColumnHeaders.Add , , "行号"
- For i = 1 To UBound(arr, 2)
- .ColumnHeaders.Add , , arr(1, i)
- Next
- .FullRowSelect = True
- .Gridlines = True
- .LabelEdit = lvwManual
- .View = lvwReport
- End With
- For i = 2 To UBound(arr) '为“查询单据”按钮添加菜单
- If Not d.Exists(arr(i, 1)) Then
- d(arr(i, 1)) = ""
- Toolbar1.Buttons(5).ButtonMenus.Add = arr(i, 1)
- End If
- Next
- End Sub
复制代码 |
|