[Resolved] Listview with Multi columns to array?
I am currently using the following code to store all of the items from a listbox control in an array, and then build a string based on the array items, trimming the last two character of the string to remove the ", ". I am looking to do something similiar for my multicolumn listview control but am concerned about how to store the multiple subitems for each item in the array.
Code:
Dim myStr (listbox1.items.count) as String
'store all active medications information in an array & build a string
For i As Integer = 0 To listbox1.Items.Count - 1
myStr(i) = listbox1.Items.Item(i).ToString
Next
myStrResult = String.Join(", ", myStr)
myStrResult = Left(myStrResult, Len(myStrResult) - 2)
Thanks for any suggestions.
-Jeremy
Re: Listview with Multi columns to array?
try this:
vb Code:
Dim myStrResult As String = ""
Dim myStr(ListView1.Items.Count - 1, ListView1.Columns.Count - 1) As String
'store all active medications information in an array & build a string
For y As Integer = 0 To ListView1.Items.Count - 1
For x As Integer = 0 To ListView1.Columns.Count - 1
myStr(y, x) = ListView1.Items(y).SubItems(x).Text
myStrResult &= myStr(y, x) & ", "
Next
myStrResult = myStrResult.Substring(0, myStrResult.Length - 2)
myStrResult &= Environment.NewLine
Next
Re: Listview with Multi columns to array?