'
'
'原创: 许仙; qq:19030300 主页:http://hot1kang1.126.com
'转载请保持信息的完整性 谢谢
'刚接触ListView 控件写的
Private Sub Command1_Click()
Dim i, mRow As ListItem
lsvEMail.SmallIcons = ImageList1 '关联图标
' For i = 1 To 10
' lsvEMail.ListItems.Add i, , i & "aa"
' lsvEMail.ListItems(i).SubItems(1) = i & "bb"
' lsvEMail.ListItems(i).SubItems(2) = i & "cc"
' lsvEMail.ListItems(i).ListSubItems.Item(2).ReportIcon = 2 '将 第2列加入图标
' lsvEMail.ListItems(i).SubItems(3) = i & "ddd"
' lsvEMail.ListItems(i).SmallIcon = i
' Next
'
For i = 1 To 20
Set mRow = lsvEMail.ListItems.Add(, , i)
mRow.SubItems(1) = i & "bb"
mRow.SubItems(2) = i & "cc"
mRow.ListSubItems.Item(2).ReportIcon = 2
'将 第2列加入图标
mRow.SubItems(3) = i & "ddd"
Next
For j = 1 To lsvEMail.ListItems(2).ListSubItems.Count '第2列变粗体
lsvEMail.ListItems(2).ListSubItems.Item(j).Bold = True
Next
End Sub
Private Sub Form_Load()
lsvEMail.HideSelection = 0
lsvEMail.View = lvwReport
Dim i
For i = 0 To 5
lsvEMail.ColumnHeaders.Add , , "标题" & i, 1800
Next
End Sub
Private Sub lsvEMail_DblClick()
' lsvEMail.MultiSelect
'lsvEMail.SelectedItem.Index '对应行的索引
MsgBox lsvEMail.SelectedItem.ListSubItems(2).Text
End Sub
Private Sub lsvEMail_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
' lsvEMail.ListItems(lsvEMail.HitTest(x, y).Index).ForeColor = &HFF&
' Text1.Left = ListView1.ListItems(ListView1.HitTest(x, y).Index).Left + ListView1.Left
'Text1.Top = ListView1.ListItems(ListView1.HitTest(x, y).Index).Top + ListView1.Top
'Text1.Height = ListView1.ListItems(ListView1.HitTest(x, y).Index).Height
'Text1.Width = ListView1.ListItems(ListView1.HitTest(x, y).Index).Width
lsvEMail.ListItems.Remove (lsvEMail.HitTest(x, y).Index)
End Sub