DragDrop vs. Click events

  • Thread starter Thread starter HaySeed
  • Start date Start date
H

HaySeed

Captutring a mouseDown event and instituting a "DragDrop" operation seems to
keep the Click event from firing.

void ColumnHeader_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
this.DoDragDrop(this, DragDropEffects.Copy);
}
}

Is there a way to have both? When a user presses the mouse down on a
Control and drags - it should invoke a DragDrop operation, when they Click
the header it should invoke a Click.

Any suggestions?
 
Captutring a mouseDown event and instituting a "DragDrop" operation seems to
keep the Click event from firing.

void ColumnHeader_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
this.DoDragDrop(this, DragDropEffects.Copy);
}
}

Is there a way to have both? When a user presses the mouse down on a
Control and drags - it should invoke a DragDrop operation, when they Click
the header it should invoke a Click.

Any suggestions?

Since you have to click before you can drag, I assume you mean if you
press the mouse button and let it up without moving the mouse you want
click processing, and if the mouse moves you want to start a drag.

You could start the drag when the mouse moves while the button is
pressed. It might be necessary to allow a little bit of movement
without starting a drag. You also might want to do the click
processing on MouseUp instead of click, depending on whether or not
you want the click processing to occur when the user does a drag.
 
Back
Top