Here's a simple illustration of how to search a ListView for a ListViewItem that matches a string, and how to get the match's SubItem, test to see if it is convertible to a number, and convert it to a number.
private void button1_Click(object sender, EventArgs e)
{
ListViewItem foundItem = listView1.FindItemWithText(textBox1.Text, false, 0, false);
if (foundItem != null)
{
string numberCandidate = foundItem.SubItems[1].Text;
int idCandidate;
if (Int32.TryParse(numberCandidate, out idCandidate))
{
MessageBox.Show("ID #" + idCandidate.ToString());
}
}
}
If you focus on understanding what happens in this code, you should be able to adapt it to meet your needs.
Note: 'FindItemText with only a string parameter supplied will return "partial matches:" if you searched on "Al, and your ListView had Items titled "Alex," and "Alice," it would return whichever entry came first in the ListViewItems collection. In the code above we supply the optional argument (last argument) to 'FindItemText that "turns off" finding partial-matches.
Note: 'FindItemText will ignore whether your search string is upper- or lower- case.