View previous topic :: View next topic |
Author |
Message |
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Mon Apr 04, 2005 4:15 pm Post subject: Drag'n'drop + modifier keys |
|
|
How do I use modifier keys when doing drag and drop operations (shift, ctrl, alt)?
I'm using OnRowDrop() to do the dropping, but how do I change the dropeffect according to modifier keys? I've tried RowDropEffect(), but I can't find out how to obtain the keys from there, since GetRowDropEffectEventArgs inherits from EventArgs and not Windows.Forms.DragEventArgs. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Apr 04, 2005 11:09 pm Post subject: |
|
|
Override the RowDropEffect method and set the drop effect as follows:
if (Control.ModifierKeys == Keys.Control)
return DragDropEffects.Copy;
else
return DragDropEffects.Move; _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Wed Apr 06, 2005 10:06 am Post subject: |
|
|
Ah, thanks! I did override the RowDropEffect, but I'm new to windows forms, and didn't guess what 'Control' is - I think this is hinted to somewhere in the help pages. Perhaps a full qualification of the element would help? Ie. System.Windows.Forms.Control.ModifierKeys.
You could also make it a bit easier for users by letting the default RowDropEffect set the effect according to modifierkeys, following the standard (ctrl = copy, alt = link, shift or none = move). But that's just a userfriendly expansion option |
|
Back to top |
|
|
|