Click here to Skip to main content
15,884,770 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a ListView that populates with hundreads of items from one file and I have to edit it. I have the code below that I was able to change the data to one item at a time. I tired creating a list and I can still only delete one item.

My goal is to be able to select multiple items from the ListView and take the data from one Column and add it to an Array. That way I can run a for each statement to loop through and correct each one. The Column I need to pull information from is Column 0, any help would be great.

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

    Dim strHeap As String = Radia_Listview.SelectedItems(0).Text 'heap number
    Dim strObject As String = "C:\Temp\ASERVICE.EDM"

    Dim list As Array
    list = {strHeap}

    For Each strHeap In list
        SetZAVISValue(strHeap)
        System.Threading.Thread.Sleep(10)
        SetDATEValue(strHeap)
        System.Threading.Thread.Sleep(10)
        SetInstallValue(strHeap)

    Next

    Dim copyFrom As String = "C:\temp\ASERVICE.EDM"
    Dim copyTo As String = "\\" & strComputer & "\C$\Progra~1\Novadigm\Lib\SYSTEM\RADDBT3\SOFTWARE\ASERVICE.EDM"
    File.Copy(copyFrom, copyTo, True)
    '----------------------------------------------
    'Del_Heap.Del_TextBox.Text = Zdelete
    'Del_Heap.Show()
    '----------------------------------------------
    Radia_Listview.Items.Clear()
    Application.Radia_Query_Aservice_Button.PerformClick()


End Sub
Posted
Updated 16-Mar-12 16:50pm
v2
Comments
ProEnggSoft 16-Mar-12 22:50pm    
Edit: Capitalization corrected and code tags added - PES

1 solution

From the code it appears that you are using only the first item in the selected items.

You can loop through all the selected items as follows

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

For Each item as ListViewItem In  Radia_Listview.SelectedItems
    strHeap = item.Text 
    SetZAVISValue(strHeap)
    System.Threading.Thread.Sleep(10)
    SetDATEValue(strHeap)
    System.Threading.Thread.Sleep(10)
    SetInstallValue(strHeap)
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