0

hi sir,

when i adding items into the listview ,i have added serialno and 5 other columns ,so whenever i adding new item the serialno will increase one but my problem is when i removing a row from listview how to rearrange the serial numbers pls help me

3
Contributors
2
Replies
23
Views
3 Years
Discussion Span
Last Post by tinstaafl
0

I hope the following codes help you.

   Private Sub ButtondeleteListItem_Click(sender As System.Object, e As System.EventArgs) Handles ButtondeleteListItem.Click

            ''' First remove the selected items
            For Each litem As ListViewItem In ListView1.SelectedItems
                ListView1.Items.Remove(litem)
            Next

            ''' Check the items count is not zero
            If Not ListView1.Items.Count = 0 Then
                ''' modify the text of the item
                For Each litem As ListViewItem In ListView1.Items
                    litem.Text = "X" & (litem.Index + 1).ToString
                Next
            End If
        End Sub
0

Assuming you mean that you don't want a gap in the numbering. One way would be to loop through all the rows from the row you removed to the end and decrease the serial number by 1, for each row that's left

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.