将选定的列表视图项添加到数组中 [英] add selected listview items into an array
问题描述
我有一个ListView
,其中充满了来自一个文件的大量项目,因此我必须对其进行编辑.我有下面的代码,我能够一次将数据更改为一项.创建列表很累,我仍然只能删除一个项目.
我的目标是能够从ListView
中选择多个项目,并从一个Column
中获取数据并将其添加到Array
中.这样,我可以运行for each
语句循环遍历并更正每个语句.我需要从中获取信息的Column
是Column 0
,任何帮助都将非常有用.
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.
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
推荐答案
\ Progra〜1 \ Novadigm \ Lib \ SYSTEM \ RADDBT3 \ SOFTWARE \ ASERVICE.EDM" File.Copy(copyFrom,copyTo,真) ' ------------------------- --------------------- ' Del_Heap.Del_TextBox.Text = Zdelete ' Del_Heap.Show() ' ------------------------- --------------------- Radia_Listview.Items.Clear() Application.Radia_Query_Aservice_Button.PerformClick() 结束 子
\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
从代码中出现您仅使用所选项目中的第一个项目.
您可以按以下步骤遍历所有选定的项目
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
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
这篇关于将选定的列表视图项添加到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!