DragDrop vs. Click events

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?
 
J

Jack Jackson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top