views:

97

answers:

2

hi all i'm trying to perform an action once the user double clicks on an item in the listview.

but there doesnt appear to be any methods available for this. can anybody please help me out here?

thanks lots :D

ANSWER (Thanks to Kyle's link):


    private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        if (listView1.Items.Count >= 1)
            Process.Start(listView1.SelectedItems[0].Text);
    }
+1  A: 

Have a look at this blog. Should help you do what you want to.

Kyle Rozendo
thank you very much Kyle
baeltazor
Glad it helped, A pleasure :)
Kyle Rozendo
+3  A: 

You could handle the doubleclick method of the ListView and then loop through each selected item. Something like:

 private void thelistview_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        foreach(ListViewItem item in thelistview.SelectedItems)
        {
            //do something with item
        }

    }

You also need to hook up the event unless you do it in the designer...

thelistview.MouseDoubleClick += 
new System.Windows.Forms.MouseEventHandler(this.thelistview_MouseDoubleClick);
Robban
thank you for this great answer too Robban :)
baeltazor