Jonathan,
I saw I had no nice sample of a listview, so I made it this morning
\\\Sample needs only a form the rest is made dynamicly
Friend WithEvents bt As New Button
Friend WithEvents lv As New ListView
Friend WithEvents ch1 As New ColumnHeader
Friend WithEvents ch2 As New ColumnHeader
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim lvi1 As ListViewItem = New ListViewItem(New String() {"1", "One"}, -1)
Dim lvi2 As ListViewItem = New ListViewItem(New String() {"2", "Two"}, -1)
Dim lvi3 As ListViewItem = New ListViewItem(New String() {"3",
"Three"}, -1)
Dim lvi4 As ListViewItem = New ListViewItem(New String() {"4",
"Four"}, -1)
Dim lvi5 As ListViewItem = New ListViewItem(New String() {"5",
"Five"}, -1)
lv.Columns.AddRange(New ColumnHeader() {ch1, ch2})
lv.Items.AddRange(New ListViewItem() {lvi1, lvi2, lvi3, lvi4, lvi5})
lv.Location = New System.Drawing.Point(10, 10)
lv.Name = "ListView1"
lv.Size = New System.Drawing.Size(150, 150)
lv.TabIndex = 0
lv.View = View.Details
bt.Location = New System.Drawing.Point(10, 200)
bt.Text = "Click Me"
Controls.Add(lv)
Controls.Add(bt)
End Sub
Private Sub bt_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles bt.Click
lv.Items.RemoveAt(2)
For i As Integer = 2 To lv.Items.Count - 1
lv.Items(i).Text = CStr(CInt(lv.Items(i).Text) - 1)
Next
End Sub
///
I hope this helps a little bit?
Cor
"Jonathan"
Hi,
I have a listview with many rows init. The first column is "No." which
shows
the row number in the listview.
When a user selected a row and delete it, say row 3.
I want to organise the number again. eg. 1,2,4,5. to 1,2,3,4. so the
listview always show the correct row number.
what is the best way to do it? many thanks.