Dim sl As ListItem Set sl = ListView1.ListItems.Add(index,key,text, , 1)
up~~~~~~~~~~选中一行时,改变此行ico图表
如何实现 选中一行时,改变此行ico图标?
Option ExplicitDim OldClick As LongPrivate Sub Form_Load() OldClick = 1
With Me.ImageList1 .ImageHeight = 25 .ImageWidth = 25 With .ListImages .Add 1, , Me.Image1 .Add 2, , Me.Image2 End With End With
With ListView1 .SmallIcons = Me.ImageList1 With .ColumnHeaders .Add , , "AA" .Add , , "BB" .Add , , "CC" End With With .ListItems .Add , , "1dfsd", , 1 .Add , , "2dfsd", , 1 .Add , , "3dfsd", , 1 .Add , , "4dfsd", , 1 End With End With End SubPrivate Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim CurListitem As ListItem Dim Flag As Boolean
Set CurListitem = Me.ListView1.HitTest(x, y) Flag = False
If Not CurListitem Is Nothing Then If CurListitem.Index <> OldClick Then Me.ListView1.ListItems(OldClick).SmallIcon = 1 End If
CurListitem.SmallIcon = 2 OldClick = CurListitem.Index Flag = True End If
If Flag = False Then Me.ListView1.ListItems(OldClick).SmallIcon = 1 End If Set CurListitem = Nothing
Set sl = ListView1.ListItems.Add(index,key,text, , 1)
OldClick = 1
With Me.ImageList1
.ImageHeight = 25
.ImageWidth = 25
With .ListImages
.Add 1, , Me.Image1
.Add 2, , Me.Image2
End With
End With
With ListView1
.SmallIcons = Me.ImageList1
With .ColumnHeaders
.Add , , "AA"
.Add , , "BB"
.Add , , "CC"
End With
With .ListItems
.Add , , "1dfsd", , 1
.Add , , "2dfsd", , 1
.Add , , "3dfsd", , 1
.Add , , "4dfsd", , 1
End With
End With
End SubPrivate Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim CurListitem As ListItem
Dim Flag As Boolean
Set CurListitem = Me.ListView1.HitTest(x, y)
Flag = False
If Not CurListitem Is Nothing Then
If CurListitem.Index <> OldClick Then
Me.ListView1.ListItems(OldClick).SmallIcon = 1
End If
CurListitem.SmallIcon = 2
OldClick = CurListitem.Index
Flag = True
End If
If Flag = False Then
Me.ListView1.ListItems(OldClick).SmallIcon = 1
End If
Set CurListitem = Nothing
End Sub
[email protected]