Private Sub lblMenu_Click(Index As Integer) strMenu = lblMenu(Index).Caption Dim m As Integer For i = 1 To Index PicMenu(i).Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height Next i ListView1.Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height If Index < 7 Then PicMenu(Index + 1).Top = ListView1.Top + ListView1.Height For i = Index + 2 To PicMenu.Count - 1 PicMenu(i).Top = PicMenu.item(i - 1).Top + PicMenu.item(i - 1).Height Next i Select Case Index Case 0 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m1.Count - 1 Key = "【" & m1.item(i).Caption & "】" m = i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 1 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m2.Count - 1 Key = "【" & m2.item(i).Caption & "】" m = i + m1.Count + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 2 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m3.Count - 1 Key = "【" & m3.item(i).Caption & "】" m = m1.Count + m2.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 3 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m4.Count - 1 Key = "【" & m4.item(i).Caption & "】" m = m1.Count + m2.Count + m3.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 4 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m5.Count - 1 Key = "【" & m5.item(i).Caption & "】" m = m1.Count + m2.Count + m3.Count + m4.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 5 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m6.Count - 1 Key = "【" & m6.item(i).Caption & "】" m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 6 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m7.Count - 1 Key = "【" & m7.item(i).Caption & "】" m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Next i Case 7 ListView1.ListItems.Clear ListView1.Enabled = True For i = 0 To m8.Count - 1 Key = "【" & m8.item(i).Caption & "】" m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + m7.Count + i + 1 Set itmX = ListView1.ListItems.Add(, , Key, m) Itemgross = m Next i End Select End Sub
ListView1。view = 2,你没改。
Set itmX = ListView1.ListItems.Add(, , Key, m) 这个m是在icon,里,在前面加个逗号,
ListView1.ListItems.Add 时,用 smallicon
Begin MSComctlLib.ImageList ImageList1 下面的code贴下,
还有
ListView1.ListItems.Add
Height = 3945
Left = 120
TabIndex = 6
Top = 3120
Width = 2160
_ExtentX = 3810
_ExtentY = 6959
LabelWrap = -1 'True
HideSelection = -1 'True
HoverSelection = -1 'True
_Version = 393217
Icons = "ImageList1"
SmallIcons = "ImageList1"
ColHdrIcons = "ImageList1"
ForeColor = -2147483640
BackColor = 16774110
Appearance = 1
NumItems = 1
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Object.Width = 2540
EndProperty
End
End Begin MSComctlLib.ImageList ImageList1
Left = 2880
Top = 2520
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 23
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":C44E
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":C768
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":D7BA
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":E80C
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":F85E
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":108B0
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":11902
Key = ""
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":12954
Key = ""
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":139A6
Key = ""
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":149F8
Key = ""
EndProperty
BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":15A4A
Key = ""
EndProperty
BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":16A9C
Key = ""
EndProperty
BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":17AEE
Key = ""
EndProperty
BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":18B40
Key = ""
EndProperty
BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":19B92
Key = ""
EndProperty
BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1ABE4
Key = ""
EndProperty
BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1BC36
Key = ""
EndProperty
BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1CC88
Key = ""
EndProperty
BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1DCDA
Key = ""
EndProperty
BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1ED2C
Key = ""
EndProperty
BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":1FD7E
Key = ""
EndProperty
BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":20DD0
Key = ""
EndProperty
BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "MDIForm1.frx":21E22
Key = ""
EndProperty
EndProperty
End
strMenu = lblMenu(Index).Caption
Dim m As Integer
For i = 1 To Index
PicMenu(i).Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height
Next i
ListView1.Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height
If Index < 7 Then PicMenu(Index + 1).Top = ListView1.Top + ListView1.Height
For i = Index + 2 To PicMenu.Count - 1
PicMenu(i).Top = PicMenu.item(i - 1).Top + PicMenu.item(i - 1).Height
Next i
Select Case Index
Case 0
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m1.Count - 1
Key = "【" & m1.item(i).Caption & "】"
m = i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 1
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m2.Count - 1
Key = "【" & m2.item(i).Caption & "】"
m = i + m1.Count + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 2
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m3.Count - 1
Key = "【" & m3.item(i).Caption & "】"
m = m1.Count + m2.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 3
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m4.Count - 1
Key = "【" & m4.item(i).Caption & "】"
m = m1.Count + m2.Count + m3.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 4
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m5.Count - 1
Key = "【" & m5.item(i).Caption & "】"
m = m1.Count + m2.Count + m3.Count + m4.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 5
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m6.Count - 1
Key = "【" & m6.item(i).Caption & "】"
m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 6
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m7.Count - 1
Key = "【" & m7.item(i).Caption & "】"
m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Next i
Case 7
ListView1.ListItems.Clear
ListView1.Enabled = True
For i = 0 To m8.Count - 1
Key = "【" & m8.item(i).Caption & "】"
m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + m7.Count + i + 1
Set itmX = ListView1.ListItems.Add(, , Key, m)
Itemgross = m
Next i
End Select
End Sub
这个m是在icon,里,在前面加个逗号,
view=2 --》item跟随光标
smallicon = imagelist
Set itmX = ListView1.ListItems.Add 用最后面的。
但(,,key,,m)能看到图标??