Aan
Aan

Reputation: 12920

Getting SubItem from listview

I am trying to get Subitem from a list view, I did this but doesn't work:

curItem1=listView2->Items[i]->Text;

curItem2=listView2->SubItem[i]->Text;

Upvotes: 3

Views: 9181

Answers (3)

chead23
chead23

Reputation: 1879

You want to access the Text property of a certain control inside the ListViews ItemTemplate. This is done similarly to this:

string curItem = ((TextBox)listView2.Items[i].FindControl("TextBox1")).Text;

Where 'TextBox1' is the control you are trying to get the Text property of. You also need to make sure that you are casting to the correct type of the Control you are trying to get the property for.

Upvotes: 0

Anish V
Anish V

Reputation: 683

Try this... ListView1.SelectedItems(0).SubItems(i).Text

Upvotes: 0

Talha
Talha

Reputation: 19282

ListViewItem selItem = listView1.Items[i];
string txt = selItem.SubItems[index].Text;

To get the Text is wrong in first line.

Upvotes: 5

Related Questions