开发者

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>.*)\}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜