Toolbox Drag & Drop Outside Control in C# |
Post Reply |
Author | |
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
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) 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:
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.
Edited by Boyd |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |