Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list view code that will take the numbers from column 0 and then in order delete them. the issue im having is once i delete the first one all the numbers are different becasue when you delete 2, 3 becomes 2. I need help starting from the highest number selected in the listview to the loest. right now the following code below starts with the lowest number.



VB
Private Sub EditHeapToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditHeapToolStripMenuItem.Click

       Dim strObject As String = "C:\Temp\ASERVICE.EDM"

       For Each sitem As ListViewItem In Radia_Listview.SelectedItems
                      AZDelete(sitem.Text)
       Next

   End Sub





so the above code gives and output of:
12345

and i need it to start with
54321
Posted

Do a loop from Radia_Listview.Items.Count to 0 doing i-- and delete them that way.
 
Share this answer
 
Comments
Zachary.shupp 21-Mar-12 8:34am    
could you provide an example i m having a hard time understanding what you mean with the count to 0 doing i
VB
'=======================================================================================
'The below code will create an array for the items that need to be deleted from Zservice
'=======================================================================================

' Delcaring the selected items as heap_num
Dim Zheap_num = CAE_Listview.SelectedItems(0).SubItems(1).Text ' heap name
Dim ZPATH As String = "\\" & strComputer & "\C$\Progra~2\Hewlett-Packard\HPCA\Agent\Lib\SYSTEM\RADIA\SOFTSRVC\ZSERVICE\"
Dim Zlist As New ArrayList

'For each selected item add the item number to an array list
For Each sITEM In Zheap_num
    Zlist.Add(sITEM)
Next

'reverse the arraylist from 012345 to 543210
Zlist.Reverse()


For Each DelZ In Zlist
    'adds the heap name to the textbox for del_heap that will display once its finished
    'deleting the items selected
    Del_Heap.Del_TextBox.Text += DelZ.text & vbCrLf

    'if the folder exist it will delete it if it dosent exist it will keep going
    If System.IO.Directory.Exists(ZPATH & DelZ.text) Then
        Directory.Delete(ZPATH & DelZ.text, True)
    End If

Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900