0

How can i JUST find out if any item in my listview has been double clicked ? ( not just clicked/one click )

I dont need to raise an action ( I dont want to use list_view1_ mouse double clicked )


Well,in my form there is an update button,so if any item has been double clicked I want to let the user proceed to another form,otherwise a message comes up and remind him to doubleClick on either of them items in list view

EXAMPLE) in my button 3 when user clicks:

if (listView1.SelectedItems.Count > 0 && **listView1_DoubleClicked**)
{
    Form3 f3 = new Form3(mod, indexAppChange);
}
else messagebox.show(" double click on an item");
farzin parsa
  • 537
  • 2
  • 9
  • 33

1 Answers1

1

You can find out by using MouseDoubleClick event.

    private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
    {

    }

The above event will fire when any item in listview is double clicked....

  • no, I dont want do anything with listview1_mouseDoubleClick event.I need to check in another button if any item has been double clicked or not – farzin parsa Mar 08 '12 at 06:10
  • put one flag in mousedoubleclick item and make the flog true only when an item is double clicked.... – Sai Kalyan Kumar Akshinthala Mar 08 '12 at 06:13
  • hooking a doubleclick event to all the items in the list seems more logical and easier/cleaner to implement. any reason to do this in another way? – Bahamut Mar 08 '12 at 06:16
  • @farzinparsa - use Sai's answer, just declare a private bool member variable called listView1_DoubleClicked and in the MouseDoubleClickevent set listView1_DoubleClicked = true. That way when users click the button you have a flag telling you if they did double click an item. Anyway +1 from me. – Jeremy Thompson Mar 08 '12 at 06:21
  • Thanks Sai and Jeremy. The best thing is ( as you advised) to declare a flag. – farzin parsa Mar 08 '12 at 17:34