C# Extracting String From ListView
I have an issue where my ListView (when showing as a string variable) keeps showing the items as ListViewItem {//item}. I wondered if there was anyway of extracting the string from between the {}?
The method I have at the moment works but is by no means how I want to be doing this.
string item = listView1.Items[i].ToString().Replace("ListViewItem: ", "").Replace("{", "").Replace("}", "");
i is from a for loop, just an incrementing number.
开发者_如何学运维Thanks
I'm not sure if this is what you want but you can use -
string item = listView1.Items[i].Text
To get the text value of the item.
I think you should be able to use the Text property:
listview1.Items[i].Text;
Ideal candidate for regex. If you match the string with the simple regex below, whatever in the group "val" value will be the text you want.
ListViewItem: \{(?<val>.*)\}
精彩评论