Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Extracting String From ListView

Tags:

string

c#

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

like image 858
Bali C Avatar asked Mar 11 '26 11:03

Bali C


1 Answers

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.

like image 92
ipr101 Avatar answered Mar 14 '26 00:03

ipr101



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!