How Pick a Column Value from a ListView Row - C#.NET

Posted by peace on Stack Overflow See other posts from Stack Overflow or by peace
Published on 2010-05-22T09:42:11Z Indexed on 2010/05/22 9:50 UTC
Read the original article Hit count: 277

Filed under:
|
|
|

alt text

  • How can i fetch the value 500 to a variable from the selected row?

One solution would be to get the row position number and then the CustomerID position number. Can you please give a simple solution.

  • SelectedItems means selected row and SubItems means the column values, so SelectedItem 0 and SubItem 0 would represent the value 500. Right?

This is how i populate the listview:

            for (int i = 0; i < tempTable.Rows.Count; i++)
            {
                DataRow row = tempTable.Rows[i];

                ListViewItem lvi = new ListViewItem(row["customerID"].ToString());
                lvi.SubItems.Add(row["companyName"].ToString());
                lvi.SubItems.Add(row["firstName"].ToString());
                lvi.SubItems.Add(row["lastName"].ToString());

                lstvRecordsCus.Items.Add(lvi);
            }

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET