ListView

  • Thread starter Thread starter Eps
  • Start date Start date
E

Eps

I have populated a listview with strings, I want something happen when
the user double clicks an item in the list view, cant find the relevant
method tho, checked the MSDN docs.

Any help appreciated.
 
Simply subscribe to the DoubleClick event of the ListBox and then use the
SelectedItem property to reference the currently selected item ala:

this.listBox1.DoubleClick += new
System.EventHandler(this.listBox1_DoubleClick);

and later:

private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
Console.WriteLine(listBox1.SelectedItem.ToString() + " is currently
selected";
}

Brendan
 
ListView is a sub-class of Control, Control exposes the DoubleClick event

...
ListView lv = new ListView();
lv.DoubleClick += new EventHandler(lv_DoubleClick);
...
private void lv_DoubleClick(object sender, EventArgs e)
{
// do stuff
}
 
Back
Top