A
Alan T
private void lvUsersList_Click(object sender, EventArgs e)
{
int userId;
ListViewItem lvi;
if (lvUsersList.SelectedItems.Count > 0)
{
lvi = lvUsersList.SelectedItems[0];
userId = Convert.ToInt32(lvi.Tag.ToString());
MessageBox.Show("User id: " + userId.ToString());
}
}
I have 2 items on a listview and would like to dispaly the id of the user.
I got no problem when I click at the first time, but got exception when I
click the second time.
The exception is:
"InvalidArgument=Value of '0' is not valid for 'index'
Parameter name: index"
{
int userId;
ListViewItem lvi;
if (lvUsersList.SelectedItems.Count > 0)
{
lvi = lvUsersList.SelectedItems[0];
userId = Convert.ToInt32(lvi.Tag.ToString());
MessageBox.Show("User id: " + userId.ToString());
}
}
I have 2 items on a listview and would like to dispaly the id of the user.
I got no problem when I click at the first time, but got exception when I
click the second time.
The exception is:
"InvalidArgument=Value of '0' is not valid for 'index'
Parameter name: index"