|
-
Aug 1st, 2010, 09:03 PM
#1
Thread Starter
New Member
How can I copy a whole listview row into a string?
I have a listbox and a button event that responds to a selection.
Is there a way to get the whole item row (including subitems) and copy it into a string? For example:
engagement = ListView1.SelectedItems(0).Text
that code does exactly what I want but only gets the main item and none of the subitems in my row.
'My Items code
Dim item1 As New ListViewItem(session(0), 0)
item1.SubItems.Add(session(1))
item1.SubItems.Add(session(2))
item1.SubItems.Add(session(3))
item1.SubItems.Add(session(4))
-
Aug 1st, 2010, 10:12 PM
#2
Re: How can I copy a whole listview row into a string?
The item has a SubItems property, which is the same collection you're adding the subitems to. Each subitem in that collection has a Text property, which contains the text displayed on-screen. You can get each of those Text properties and join them together into a single string. There are various ways you can do that. The first that comes to mind is a For or For Each loop. Try implementing a loop yourself and see what you can come up with. Note that the first subitem contains the same data as the item itself, so you don't have to treat the first column differently.
-
Aug 1st, 2010, 11:01 PM
#3
Thread Starter
New Member
Re: How can I copy a whole listview row into a string?
Thanks so much. I did not know about that property. I actually did not need to write them into one string, they suited me individually.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|