Private Sub Command1_Click()
ListView1.ListItems.Remove 2 '删除其中一项
End Sub
Private Sub Command2_Click() '排序 直接修改第一列的值
For i = 1 To ListView1.ListItems.Count
ListView1.ListItems(i).Text = i
Next
End Sub
Private Sub Form_load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , "", "第一列"
ListView1.ColumnHeaders.Add , "", "第二列"
ListView1.ColumnHeaders.Add , "", "第三列"
Dim itmX As ListItem
For i = 1 To 5
Set itmX = ListView1.ListItems.Add(i, "", i)
Next
End Sub
你说得有点不明白。排序的号可以点击删除一行以后,执行以下动作:
ListView1.Sorted = True
ListView1.SortKey = ListView.ColumnHeaders(0).Index ‘这里的0是列,要根据实际情况
ListView1.SortOrder = lvwAscending ’这里选择升序,你可以改成降序lvwDescending ,也可以改成点一下升序,再点一下降序
既然原先有排序,无论你删除哪几个,顺序是不变的,根本不需要重新排序