DoubleClick broken by drag drop

  • Thread starter Thread starter Mike Oliszewski
  • Start date Start date
M

Mike Oliszewski

As a continuation of my previous posting regarding drag and drop, we have
additionally realized now that adding drag capabilities to the DataGridView
kills the DoubleClick event. While this seems like it would be easy to
manually create this on our own, we don't know how to access the systems
configuration for double click timing and it seems as though there should be
a better way to do this.

Any advise would be greatly appreciated!!!
 
As a continuation of my previous posting regarding drag and drop, we have
additionally realized now that adding drag capabilities to the DataGridView
kills the DoubleClick event. While this seems like it would be easy to
manually create this on our own, we don't know how to access the systems
configuration for double click timing and it seems as though there should be
a better way to do this.

Any advise would be greatly appreciated!!!

This is a problem with any control. Once you call DoDragDrop, you are
dragging and double click won't work.

The way I deal with this is:

In the MouseDown event, if I want to allow dragging, I calculate a
small rectangle about 5 pixels by 5 pixels around the mouse pointer
and remember it.

In MouseMove, if I have a remembered rectangle and the mouse pointer
is not contained within the rectangle, I call DoDragDrop and clear the
remembered rectangle.

The drag/drop doesn't start until the mouse is moved a couple of
pixels, which allows for double-click as long as the mouse is not
moved more than a couple of pixels while the mouse button is
depressed.
 
I have tried this approach and it has yet another side affect. If you are
needing to support multiselect drags (as I do) then this lets the
DataGridView process the mouse down, which clears the selected items. So you
either get double click supported or you get mutli-select drag drop, but not
both. Given this is the default behavior of nearly every Windows application
I need to figure out how to do it properly in .NET.
 
Back
Top