The last index of selected items will always be the 9, but the item will always be the heaviest in the list: if you select from 10 to 1, the last selected item will not be the last in time operation index but will always be the heaviest (the 10th item) and the associated item will always be the tenth in the original list, not the first. I did not tested the whole combinations of items, but it seems as if:
I have made only a small test with a list of 4 string items and havng the listview show smallicon. It would be item # 9Last as biggest or last in time? I do believe quester was looking for last in time operation. You still select the LAST ITEM in the list (assuming 10 items). Sb.Remove(sb.Length - sep.Length, sep.Length)ĭoesn't matter if you start at 10 and go back to 1, or the reverse. & " and the text is """ & ListView1.Items(itemsSelectedIndex(itemsSelectedIndex.Count - 1)).Text _įor Each idx As Integer In itemsSelectedIndex MessageBox.Show("last selected item index is " & itemsSelectedIndex(itemsSelectedIndex.Count - 1).ToString() _ 'all the indexes of the items that have been selected in theĭim sb As New () 'i will show you last select index,but I also "print" 'the following is to show the order is preserverd. Private Sub btnCheckSelected_Click(sender As System.Object, e As System.EventArgs) Handles btnCheckSelected.Click
'show what you have in your list: it is ordered as entries has been added Private Sub ListView1_ItemSelectionChanged(sender As System.Object, e As ) Handles ListView1.ItemSelectionChanged 'handle the selections : add /remove indexes of any item selected or deselected to your list ' I fill the listview with some elements.ĭim ListViewItem1 As ListViewItem = New ListViewItem("item 1")ĭim ListViewItem2 As ListViewItem = New ListViewItem("item 2")ĭim ListViewItem3 As ListViewItem = New ListViewItem("item 3")ĭim ListViewItem4 As ListViewItem = New ListViewItem("item 4") Txt_profit.Private itemsSelectedIndex As New List(Of Integer) Txt_total.Text = FormatNumber(total_price) In my project, I use the code below (It is working): Private Sub ListView1_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles ListView1.ItemChecked Select Case MsgBox("Are you sure you want to delete selected record?", MsgBoxStyle.YesNo, "Confirm Delete") Step2 Using this code: Private Sub ListView1_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles ListView1.ItemChecked Step1 Changing ListView1 properties following below picture enter image description here