Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Suite Pro
  New Posts New Posts RSS Feed - Toolbox Drag & Drop Outside Control in C#
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Toolbox Drag & Drop Outside Control in C#

 Post Reply Post Reply
Author
Message
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Topic: Toolbox Drag & Drop Outside Control in C#
    Posted: 16 February 2005 at 3:22pm

I have a problem allowing Drag/Drop of Toolbox items outside of the toolbox.  I'm working in Visual C# 2003.  I want to be able to rearrange the items within the toolbox (through drag/drop), but I also want to be able to drag/drop an item on a control outside the toolbox.

I have set all the 'AllowDrag' and 'AllowDrop' properties so that everything works within the control itself.  When I drop an item on a control outside the toolbox, I get some XML text indicating what was dropped.  This is obviously the default text for the object that's dropped.  Each item in my toolbox represents a snippet of text (like previous text values copied to the clipboard), so the text I want to have dropped on the other control is the underlying text that I have stored in the 'Tag' property of the item.

In the .NET world, you work with DragDrop event through classes that inherit from the IDataObject interface.  You initialize a DragDrop routine by calling the 'DoDragDrop' method and pass it an IDataObject.  I placed the following code in the 'BeginDrag' event of the toolbox:

if (e.item.Tag is string)
    DoDragDrop(e.item.Tag.ToString(), DragDropEffects.Copy);

This works great for dropping the text stored in the Tag property on a control outside the application.  The problem now is that Drag/Drop functionality within the control itself will no longer work.

At this point, I have to decide between internal drag/drop functionality or external drag/drop functionality, but not both.  The default text used for drag/drop just won't work.

Is there any chance of enhancing the events for drag/drop?  If you at least exposed a 'DragLeave' event for when the user drags off the control, I could wait to call the 'DoDragDrop' method until the user actually drags off the control.

The following events are available within .NET and provide all the flexibility you would need for handling drag/drop:

  1. QueryContinueDrag - validates if drag/drop should continue
  2. DragDrop - item is dropped on the control
  3. DragEnter - drag operation enters the control for the first time
  4. DragLeave - drag operation leaves the control
  5. DragOver - drag occurs over the control

Of these useful events, we only have equivalents for 'DragDrop' (through ItemDrop event) and 'DragEnter' (through BeginDrag event).  Those of use using ActiveX versions of your controls have to rely on events being exposed for the controls.

  1. Do you have any suggestions for working with Drag/Drop in .NET or is there a chance some of these events will be added in a future release? 
  2. Also, since I don't want people to be able to drop an item outside the control (since it results in that XML data), can I allow drag/drop within an control but prevent drag/drop outside the control?
  3. Finally, how do I make an item drag in 'Copy' mode so that the original item is not removed from the Toolbox after the drag/drop operation outside the control?


Edited by Boyd
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2005 at 1:24pm
In the next release you can specify the drag and drop options for each individual group and group item.  For example, you can specify that the item can only be "copied" and not removed.  Take a look at the XTPTaskPanelItemAllowDrag enumeration in the next release
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.