Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DragDrop and Click
Message
De
06/08/2004 15:50:48
 
 
À
06/08/2004 09:51:33
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00931162
Message ID:
00931415
Vues:
15
>The example in the online Help "Performing Drag-and-Drop Operations in Windows Forms" suggest that the dodragdrop be called from the mousedown event, although you could call this from any event. I can do drag and drop with the button, but I want the user to be able to click the button or click and drag the button over a target area, without having to use some odd key combination.

The help isn't always very helpful. <g> Some controls (ListView, TreeView) have an ItemDrag event, into which you can put call the DoDragDrop() method. These are the only two controls from which I was doing drag/drop, so that's why I said that you didn't need to use the Mousedown event ... in these two situations, that statement is true.

However, that doesn't help you much. So, I started playing around with drag/dropping a Button and you're right about the problem with firing the .Click() if you put the call to DoDragDrop() in the MouseDown event handler. Same is true of MouseMove. However, I discovered that you could use the MouseHover event just fine. So, if the user simply goes to the button and clicks, the Click event will fire. If the user hovers a bit over the button and then clicks and drags, the drag stuff will happen. Works like a charm. Have fun!

~~Bonnie



>
>>>I would like to be able to click a button or dragdrop the button. If I put code in the mousedown to handle the dragdrop, the click event doesn't fire. You could do this in VB6 and VFP by setting the dragmode to manual.
>>
>>There are several drag/drop properties and events where you should put code for handling drag/drop. Nothing is needed in the mousedown event. I haven't tested this to see whether the button's click event will still fire this way, but I might have time to look at it later. The whole drag/drop scenario is a bit tricky until you get the hang of it, but it's not really all that hard. I believe the latest CoDe magazine had an article on drag/drop. I've done drag/drop also, but I don't have any specific "how-to" stuff compiled as yet. If you don't subscribe to CoDe magazine, perhaps I can take some time to put together a few code snippets for a how-to. Lemme know if you need it ...
>>
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform