Saving ListView SubItems To A SortedList

E

enchantingdb

I'm trying to add the contents of a ListView to a SortedList. The
ListView contains two columns - "Title" and "URL". I need to add both
columns to the SortedList with Title being the Value and URL being the
Key. I can get the information into and out of the SortedList but when
I add the URL into the SortedList it is in the form "ListViewSubItem:
{http://...}". The code I use for this is...

ListView.CheckedListViewItemCollection collection = lv.CheckedItems;

foreach (ListViewItem item in collection)
{
sl.Add(item.Text, item.SubItems[2].ToString());
}

Is there a way to extract the data from the second column without
having the extra data being added?

Rob
 
J

Jeff Gaines

I'm trying to add the contents of a ListView to a SortedList. The
ListView contains two columns - "Title" and "URL". I need to add both
columns to the SortedList with Title being the Value and URL being the
Key. I can get the information into and out of the SortedList but when
I add the URL into the SortedList it is in the form "ListViewSubItem:
{http://...}". The code I use for this is...

ListView.CheckedListViewItemCollection collection = lv.CheckedItems;

foreach (ListViewItem item in collection)
{
sl.Add(item.Text, item.SubItems[2].ToString());
}

Is there a way to extract the data from the second column without
having the extra data being added?

Rob

How about:

sl.Add(item.Text, item.SubItems[2].Text);

???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top