New to Telerik UI for WinForms? Start a free 30-day trial

Coordinates node drag-and-drop operations and their feedback for a TreeView element.

Definition

Namespace:Telerik.WinControls.UI

Assembly:Telerik.WinControls.UI.dll

Syntax:

C#
public class TreeViewDragDropService : RadDragDropService, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, IMessageListener

Inheritance: objectDisposableObjectRadObjectRadServiceRadDragDropServiceTreeViewDragDropService...

Derived Classes: DataFilterDragDropService

Implements: ICustomTypeDescriptorIDisposableIMessageListenerINotifyPropertyChanged

Inherited Members RadDragDropService.messageFilterAddedRadDragDropService.xOutlineFormOffsetRadDragDropService.yOutlineFormOffsetRadDragDropService.beginPointRadDragDropService.HandleLeftButtonUp()RadDragDropService.HandleEscKeyDown()RadDragDropService.RestoreOriginalMouseCursor()RadDragDropService.ShouldBeginDrag(Point, Point)RadDragDropService.OnPreviewDragStart(PreviewDragStartEventArgs)RadDragDropService.Commit()RadDragDropService.GetDropTarget(Point, out Point)RadDragDropService.OnPreviewDropTarget(PreviewDropTargetEventArgs)RadDragDropService.BeginDrag(Point, ISupportDrag)RadDragDropService.EndDrag(Point, RadControl)RadDragDropService.EndDrag()RadDragDropService.DoMouseMove(Point)RadDragDropService.CanCommitRadDragDropService.ValidCursorRadDragDropService.InitializedRadDragDropService.InvalidCursorRadDragDropService.UseDefaultPreviewRadDragDropService.DropTargetRadDragDropService.DropLocationRadDragDropService.HintWindowRadDragDropService.PreviewDragDropRadDragDropService.PreviewDragOverRadDragDropService.PreviewDropTargetRadDragDropService.PreviewDragStartRadDragDropService.PreviewDragHintRadService.CanOperate()RadService.Start(object)RadService.Stop(bool)RadService.Pause()RadService.Resume()RadService.OnStarting(RadServiceStartingEventArgs)RadService.IsContextValid(object)RadService.Abort()RadService.PerformResume()RadService.PerformPause()RadService.SetContext(object)RadService.OnEnabledChanged()RadService.ContextRadService.AvailableAtDesignTimeRadService.StateRadService.NameRadService.EnabledRadService.StartingRadService.StartedRadService.StoppingRadService.StoppedRadObject.BindingContextPropertyRadObject.RadTypeRadObject.ReplaceDefaultDescriptors(PropertyDescriptorCollection)RadObject.ClearPropertyStore()RadObject.SuspendPropertyNotifications()RadObject.ResumePropertyNotifications()RadObject.GetPropertyValue(RadProperty)RadObject.SetDefaultValueOverride(RadProperty, object)RadObject.GetValue(RadProperty)RadObject.SetValue(RadProperty, object)RadObject.ResetValue(RadProperty)RadObject.ResetLocalValue(RadProperty)RadObject.ResetValue(RadProperty, ValueResetFlags)RadObject.UpdateValue(RadProperty)RadObject.GetValueSource(RadProperty)RadObject.GetRegisteredRadProperty(string)RadObject.UpdateValueCore(RadPropertyValue)RadObject.SetValueCore(RadPropertyValue, object, object, ValueSource)RadObject.ResetValueCore(RadPropertyValue, ValueResetFlags)RadObject.GetDefaultValue(RadPropertyValue, object)RadObject.CoerceValue(RadPropertyValue, object)RadObject.ShouldSerializeProperty(RadProperty)RadObject.CanRaisePropertyChangeNotifications(RadPropertyValue)RadObject.BindProperty(RadProperty, RadObject, RadProperty, PropertyBindingOptions)RadObject.UnbindProperty(RadProperty)RadObject.AddStylePropertySetting(IPropertySetting)RadObject.GetInheritedValue(RadProperty)RadObject.OnPropertyChanging(RadPropertyChangingEventArgs)RadObject.OnPropertyChanged(RadPropertyChangedEventArgs)RadObject.OnNotifyPropertyChanged(string)RadObject.OnNotifyPropertyChanged(PropertyChangedEventArgs)RadObject.OnShouldSerializeProperty(ShouldSerializePropertyEventArgs)RadObject.IsPropertyCancelable(RadPropertyMetadata)RadObject.PropertyValuesRadObject.PropertyFilterRadObject.RadObjectTypeRadObject.BindingContextRadObject.PropertyChangedRadObject.RadPropertyChangedRadObject.RadPropertyChangingDisposableObject.GetBitState(long)DisposableObject.SetBitState(long, bool)DisposableObject.OnBitStateChanged(long, bool, bool)DisposableObject.Dispose()DisposableObject.Dispose(bool)DisposableObject.PerformDispose(bool)DisposableObject.DisposeUnmanagedResources()DisposableObject.BitStateDisposableObject.EventsDisposableObject.IsDisposingDisposableObject.IsDisposedDisposableObject.DisposedDisposableObject.Disposing...

Constructors

Creates a drag-and-drop service for the specified TreeView element.

C#
public TreeViewDragDropService(RadTreeViewElement owner)
Parameters:ownerRadTreeViewElement

The element whose nodes are handled by this service.

Properties

Gets or sets the solid color used to draw the drop-position line.

C#
public Color DropHintColor { get; set; }

When this value is Empty, the target tree's ItemDropHint supplies the image when available. For a cross-tree drop using this fallback, the source tree's ItemDropHint is also read for positioning and must be non-null.

Gets whether the built-in node-transfer paths should copy rather than move nodes because the Alt key is held.

C#
protected virtual bool IsCopyingNodes { get; }

Gets the TreeView element whose nodes this service handles.

C#
protected RadTreeViewElement Owner { get; }

Gets or sets a value indicating whether drag hint should be shown.

C#
public bool ShowDragHint { get; set; }
Property Value:

true if [show drag hint]; otherwise, false.

Gets or sets a value indicating whether show drop hint should be shown.

C#
public bool ShowDropHint { get; set; }
Property Value:

true if [show drop hint]; otherwise, false.

Methods

Determines whether the drop event has already been handled and should not be processed by this service.

C#
protected virtual bool CancelPreviewDragDrop(RadDropEventArgs e)
Parameters:eRadDropEventArgs

The pending drop event.

Returns:

bool

true when the event is already handled; otherwise, false.

Rejects invalid node placements and otherwise prepares target expansion or auto-scroll feedback as needed.

C#
protected virtual bool CanDragOver(DropPosition dropPosition, TreeNodeElement targetNodeElement)
Parameters:dropPositionDropPosition

The proposed placement relative to the target node.

targetNodeElementTreeNodeElement

The row being considered as a drop target.

Returns:

bool

true when the selected nodes can be dropped at the proposed position.

Determines whether the pointer is over the before-node or after-node area where a line hint is shown.

C#
protected virtual bool CanShowDropHint(Point mousePosition)
Parameters:mousePositionPoint

The pointer position in screen coordinates.

Returns:

bool

true when a node target exists, drop hints are enabled, and the pointer is outside the row's child-drop area.

Allows dragging only when the base service permits it, the owner is not editing, and drag-and-drop is enabled.

C#
protected override bool CanStart(object context)
Parameters:contextobject

The object proposed as the drag context.

Returns:

bool

true when all drag-start conditions are met.

Overrides: RadDragDropService.CanStart(object)

Creates a new tree node in the target RadTreeView using the information from the source tree.

C#
protected virtual RadTreeNode CreateTreeNode(RadTreeNode sourceTreeNode)
Parameters:sourceTreeNodeRadTreeNode

The source tree node.

Returns:

RadTreeNode

A new instance of RadTreeNode if successfull.

Disposes the current layered drop-hint window, if one has been created.

C#
protected virtual void DisposeHint()

Clears cached drag state and releases the drop-hint window.

C#
protected override void DisposeManagedResources()

Overrides: RadDragDropService.DisposeManagedResources()

Gets the selected nodes eligible to move, excluding descendants of another selected node.

C#
protected virtual List<RadTreeNode> GetDraggedNodes(RadTreeNode draggedNode)
Parameters:draggedNodeRadTreeNode

The node that initiated the drag.

Returns:

List<RadTreeNode>

The selected root nodes to transfer, or the initiating node when no selected node is eligible.

Maps a pointer location within a target row to a before, after, or child drop position.

C#
protected DropPosition GetDropPosition(Point dropLocation, TreeNodeElement targetNodeElement)
Parameters:dropLocationPoint

The pointer location in the target row's coordinate system.

targetNodeElementTreeNodeElement

The row under the pointer.

Returns:

DropPosition

The drop position determined by the row's vertical thirds.

Copies the source tree's current selection before the drop changes it.

C#
protected virtual List<RadTreeNode> GetSelectedNodes(RadTreeNode draggedNode)
Parameters:draggedNodeRadTreeNode

The node that initiated the drag.

Returns:

List<RadTreeNode>

A list containing the nodes selected in the source tree.

Raises item-drag notifications and creates, positions, or disposes the node drop-hint window as the pointer moves.

C#
protected override void HandleMouseMove(Point mousePosition)
Parameters:mousePositionPoint

The current pointer position in screen coordinates.

Overrides: RadDragDropService.HandleMouseMove(Point)

Hides the active drag hint window.

C#
public void HideHintWindow()

Rejects the node being dragged as its own drop target before applying the base target validation.

C#
protected override bool IsDropTargetValid(ISupportDrop dropTarget)
Parameters:dropTargetISupportDrop

The proposed drop target.

Returns:

bool

false for the dragged node itself; otherwise, the base service's validation result.

Overrides: RadDragDropService.IsDropTargetValid(ISupportDrop)

Processes a drop by notifying handlers, transferring accepted nodes, and updating the affected trees' selection.

C#
protected override void OnPreviewDragDrop(RadDropEventArgs e)
Parameters:eRadDropEventArgs

The drop target, location, and handled state for this drag operation.

Overrides: RadDragDropService.OnPreviewDragDrop(RadDropEventArgs)

A handled drop is skipped by CancelPreviewDragDrop(RadDropEventArgs). Each node can also be rejected by the cancelable DragEnding event.

Applies the drag-hint visibility setting and forwards generic preview data as TreeView-specific event data.

C#
protected override void OnPreviewDragHint(PreviewDragHintEventArgs e)
Parameters:ePreviewDragHintEventArgs

The generic preview data; when drag hints are disabled, its default hint is suppressed before forwarding.

Overrides: RadDragDropService.OnPreviewDragHint(PreviewDragHintEventArgs)

The forwarded TreeViewPreviewDragHintEventArgs has a None position because this overload has no target-specific position.

Raises the preview-hint notification with the candidate position when the pointer is over a TreeView node.

C#
protected virtual void OnPreviewDragHintWithDropPosition(TreeViewPreviewDragHintEventArgs e)
Parameters:eTreeViewPreviewDragHintEventArgs

The target-specific drag-hint data, including the computed drop position.

Override this method to customize feedback by drop position. Call the base implementation to preserve the inherited preview notification.

Determines drop feedback for a tree or node target and raises DragOverNode for node targets.

C#
protected override void OnPreviewDragOver(RadDragOverEventArgs e)
Parameters:eRadDragOverEventArgs

The drag-over event containing the hit target and current drop location.

Overrides: RadDragDropService.OnPreviewDragOver(RadDragOverEventArgs)

Caches the source item's drag image after the base service starts.

C#
protected override void OnStarted()

Overrides: RadService.OnStarted()

Releases the cached source-item image before the base service stops.

C#
protected override void OnStopped()

Overrides: RadService.OnStopped()

Clears the TreeView's stored dragged node when the service is stopping without committing the operation.

C#
protected override void OnStopping(RadServiceStoppingEventArgs e)
Parameters:eRadServiceStoppingEventArgs

The service-stopping event data indicating whether the operation will be committed.

Overrides: RadService.OnStopping(RadServiceStoppingEventArgs)

Applies the drop to a target row, filtering nodes through the cancelable ending event before moving or copying them.

C#
protected virtual void PerformDragDrop(Point dropLocation, TreeNodeElement targetNodeElement, List<RadTreeNode> draggedNodes)
Parameters:dropLocationPoint

The pointer location in the target row's coordinate system.

targetNodeElementTreeNodeElement

The row receiving the drop.

draggedNodesList<RadTreeNode>

The dragged nodes; nodes rejected by the ending event are removed from this list.

Dropping as a child uses the binding provider when available; before- and after-node placements are handled by PerformDragDropCore(DropPosition, RadTreeNode, List<RadTreeNode>).

Inserts or delegates the accepted dragged nodes before or after a target node.

C#
protected virtual void PerformDragDropCore(DropPosition position, RadTreeNode targetNode, List<RadTreeNode> draggedNodes)
Parameters:positionDropPosition

The before-node or after-node placement.

targetNodeRadTreeNode

The node that determines the insertion location.

draggedNodesList<RadTreeNode>

The dragged nodes; nodes rejected by the ending event are removed from this list.

A bound tree can handle the transfer through its binding provider; otherwise nodes are cloned for copy operations or removed and inserted for move operations.

Captures the source node from the drag context after the base service initializes it.

C#
protected override void PerformStart()

Overrides: RadDragDropService.PerformStart()

Releases drop-hint resources and clears the active drag state after the base service stops.

C#
protected override void PerformStop()

Overrides: RadDragDropService.PerformStop()

Raises the cancelable starting event before preparing the drag context, then raises the started event for a TreeView node.

C#
protected override bool PrepareContext()
Returns:

bool

false when the starting event cancels the operation; otherwise, the result from the base context preparation.

Overrides: RadDragDropService.PrepareContext()

Creates a layered drop-hint image from the configured color or, when no color is set, the target tree's item-drop shape.

C#
protected virtual void PrepareDragHint(TreeNodeElement nodeElement)
Parameters:nodeElementTreeNodeElement

The target row whose tree supplies the drop-hint shape and available width.

If no color or target-tree item-drop shape is available, no hint window is created.

Positions the drag hint and, over a node, displays feedback for the computed drop position.

C#
protected override void SetHintWindowPosition(Point mousePt)
Parameters:mousePtPoint

The pointer position in screen coordinates.

Overrides: RadDragDropService.SetHintWindowPosition(Point)

The default TreeView hint combines the position marker with the cached source-item image; preview handlers can supply custom feedback.

Shows the active drag hint window.

C#
public void ShowHintWindow()

Positions the drop-hint window at the target row's before-node or after-node edge.

C#
protected virtual void UpdateHintPosition(Point mousePosition)
Parameters:mousePositionPoint

The pointer position in screen coordinates.