views:

116

answers:

4

In my C# app, I have a ListView on a Form. I want the user to be able to double-click on a section of the ListView when no items are selected in order to pop up a "New Item" dialog. The problem is that the DoubleClick event for the ListView only fires if an item is selected.

Is there a way to do this?

A: 

Add an event handler for the List view's MouseDoubleClick event.

sechastain
+1  A: 

There is a way to do this, but you have to do some low-level drilling into the Windows machinery. It's generally not a good idea to spend a great deal of time trying to get a standard Windows control to behave in a non-standard manner.

A simpler way is to just put a "New Item" button next to your ListView. If screen real estate is an issue, you could just add an extra row at the bottom that says "{click here to add new item}", and show your dialog when the user clicks this last row.

MusiGenesis
A: 

Please read the article "[Block ItemCheck event if user double clicks an item in the ListView control (.NET control)"][1] http://justin-yue.spaces.live.com/blog/cns!916677F29D07BD0!211.entry?&_c02_vws=1

Justin
A: 

Assuming Windows Forms:

Perhaps a good workaround would be to use a ContextMenu.

Will Marcouiller