ListBox/ListView selection

L

Liz

I have used a ListView with several columns and lines to
display an array

ListView1.Items.Clear();
ListView1.Items.Add(aClients[1].Id);
ListView1.Items.Add(aClients[2].Id);

ListView1.Items[0].SubItems.Add(aClients[1].Surname);
ListView1.Items[0].SubItems.Add(aClients[1].Forename);
ListView1.Items[1].SubItems.Add(aClients[2].Surname);
ListView1.Items[0].SubItems.Add(aClients[2].Forename);

I wish to catch when a selection is made from this
ListView but can only find one for ListBox. Is there an
equivalent of code below for ListView??

private void ListBox1_SelectedIndexChanged(object
sender, System.EventArgs e)
{
if ((string)ListBox1.SelectedItem == "2")
MessageBox.Show((string)listBox1.SelectedItem);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top