Gavrilo Adamovic
Gavrilo Adamovic

Reputation: 2795

Getting values of selected item in ListView with multiple fields in c#, windows forms

I have a list view with multiple fields, and the problem is that I can't get the value from columns other then the first one.

When I call lv.SelectedItems[0] I get the first column, but everything other then 0 for index gives me this error: Additional information: InvalidArgument=Value of1is not valid forindex.

Upvotes: 0

Views: 1186

Answers (1)

Selman Genç
Selman Genç

Reputation: 101681

You are probably looking for SubItems property:

var item = lv.SelectedItems[0];

var firstColumn = item.SubItems[0].Text;
var secondColumn = item.SubItems[1].Text;
...

Upvotes: 1

Related Questions