Reputation:
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?
Upvotes: 3
Views: 1005
Reputation: 24132
Assuming Windows Forms:
Perhaps a good workaround would be to use a ContextMenu
.
Upvotes: 0
Reputation: 75276
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.
Upvotes: 1
Reputation: 613
Add an event handler for the List view's MouseDoubleClick event.
Upvotes: 0