What I want to do is double-click on an empty row in the ListView and insert the item there. It already responds to the MouseDoubleClick event (for editing items), and it works fine, but it looks like MouseDoubleClick does not fire if the double-click is in the ListView part that does not contain ListViewItem.
I already tried to respond to normal MouseDoubleClick events in the dialog itself, but the event does not fire if it is in one of the "null areas" of the ListView.
Is there a way to respond to clicking on the “null areas” of a ListView without a subclass? What events / events need / need to be processed to do this?
The current response to double-clicking the dialog box (mouse and regular) looks like this:
if ( RectangleToScreen(list.ClientRectangle).Contains(eX, eY) ) list_MouseDoubleClick(sender, e);
and list_MouseDoubleClick () (where m_SelItem is the current selected item)
private void list_MouseDoubleClick(object sender, MouseEventArgs e) { if ( m_SelItem == null && m_Combo.Items.Count > 0 ) { m_SelItem = new ListViewItem(new string[] { "", "Rd" }); list.Items.Add(m_SelItem); } ... }
EDIT: It seems that the whole region is just a black hole for events. For example, I tried to respond only to the normal click / mouseclick event for ListView and Dialog. Even those that don't start if click is not included in the ListViewItem. I assume that the only solution would be a subclass.
EDIT: Persistence pays off! It turns out that I can get the desired result by responding to the "MouseDown" event as such:
private void list_MouseDown(object sender, MouseEventArgs e) { if ( e.Clicks == 2 ) list_MouseDoubleClick(sender, e); }
source share