Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For drag and drop to work effectively between SRP Tree Controls, there must be a way to identify another tree control. OpenInsight can already do this: all controls have a unique control entity identifier, the CtrlEntId. However, OLE Controls do not know what their CtrlEntId is, nor can they discover it on their own. You must tell the SRP Tree Controls, especially those to be involved in drag and drop transactions, what their CtrlEntIds are using the CtrlEntId property. Setting this property allows any other SRP Tree Control to identify it, making it much easier to transfer items between controls and to identify drag and drop sources and targets.

IMPORTANT: Always set the CtrlEntId during your CREATE event just to be safe. If you use promoted events, you can do this automatically for all controls. The code looks like this:

...

By default, the user cannot drag any items from a tree. In order to allow the user that privilege, you must set the DragEnabled property to 1. Doing so will allow the user to drag any items he/she chooses. You have two choices on how to limit the items the user can drag. The ItemDraggable property allows you to choose which items are draggable and which ones are not, though this can be tedious. An easier way is to use the DragCondition property. Using Conditions, you can specify Boolean expression that, when true, permits the user to drag an item.

...

By default, a tree control will accept drag and drop items from any SRP Tree Control. This is usually not desirable, so the DropSources property has been provided to limit valid drop sources. Simply set this property to a list of CtrlEntIds from which items are allowed to be dragged and dropped. This list can include the tree itself if you wish to be able to drag and drop within the same control.

Like source trees, all items are valid drop targets by default. This means that the user can drop items onto or in between any item. Again, you have two choices on how to limit the drop targets. The ItemDroppable property lets you be very specific about which items can be drop targets whereas the DropConditionuses  uses Conditions to automatically decide the drop targets.

Another property you may want to modify is the DropBehavior property. This property defines the kind of feedback the user will see as items are dragged over its surface. There are three drop behaviors:

...

When the user drops items onto a Target, it fires the OnDrop event. This event lets you know which items were being dropped as well as the drop source. You can use this information to implement that actual copy or move of items. To copy items, use either the SendItems or TransferItems methods. The SendItemsmethod  method sends copies of the items from one tree to another. The TransferItem does the same thing with the addition that it also copies over the items' parents.

...

The SRP Tree Control can do this work for you as long as you only need simple drag and drop. The AutoDrop property can be set to 1 to enable automatic copy of items from the Source to the Target. The Target tree uses the DropBehavior property to determine how the items are copied:

DropBehaviorActionEquivalent Method
AddCopies of the items are add to the target itemSendItems using "Add" action
InsertCopies of the items are inserted between the target itemsSendItems using "Before" or "After" action
ControlCopies of the items are added to the Target at the same location they appeared in the SourceTransferItems

Note that the items are copied, not moved. If you wish to simulate a move, simply capture the OnDrop event and call the Source tree's RemoveItems method.

See Also

DragEnabledDropSourcesDragConditionDropConditionOnDragStartOnDragEnterOnDragExitOnDropItemDraggableItemDroppable