Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

Move Method, ItemClass Class

Moves an item to a new position in the tree control.

Class: ItemClass
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public ItemClass Move( ItemCollectionClass ItemCollection );
public ItemClass Move(
    ItemClass ItemTarget,
    MoveStyleEnum Style );
Public Function Move( ByVal ItemCollection As ItemCollectionClass ) As ItemClass
Public Function Move(
    ByVal ItemTarget As ItemClass,
    ByVal Style As MoveStyleEnum
  ) As ItemClass

Parameters

ItemCollection

The item collection.

ItemTarget

Depending on the Style argument, ItemTarget specifies the target item, where the item is to be moved to, or null/Nothing if it is not required.

Style

Defines how the item is moved.

Return Value

The item object of the item after it has moved.

Comments

Moves an item to a new position in the tree control.

Items that are moved lose their selection status and are no longer selected.

An item's child items and all its other properties are automatically moved.

When moving items within the same tree control, the item object returned by the Move method is the same. When moving between tree controls, a new item object represents the moved item in the new, target tree control. The original item object is no longer valid.

The Move method accepting an ItemCollection argument is usually used when moving items to an empty tree control. The tree control's empty item collection is represented by the SftTree.ItemCollection property.

Items that are moved lose their selection status and are no longer selected.

An item's child items and all its other properties are automatically moved.

When moving items within the same tree control, the item object returned by the Move method is the same. When moving between tree controls, a new item object represents the moved item in the new, target tree control. The original item object is no longer valid.

Examples

C#

            Debug.Write("sftTree1_DragDrop ");
            DumpValues(e);
            if (sftTree1.DropTarget != null && e.Data.GetDataPresent(typeof(ItemClass))) {
                ItemClass originalItem = (ItemClass)e.Data.GetData(typeof(ItemClass));
                ItemClass targetItem = (ItemClass)sftTree1.DropTarget;
                ItemClass newItem = null;
                if (e.Effect == DragDropEffects.Move) {
                    try {
                        newItem = originalItem.Move(targetItem, MoveStyleEnum.TargetAsParentInsertFirst);
                    } catch (Exception exc) {
                        MessageBox.Show(exc.Message);
                    }
                } else {
                    try {
                        newItem = originalItem.Copy(targetItem, CopyStyleEnum.TargetAsParentInsertFirst, true);
                    } catch (Exception exc) {

VB.NET

    Debug.Write("sftTree1_DragDrop ")
    DumpValues(e)
    If Not SftTree1.DropTarget Is Nothing And e.Data.GetDataPresent(GetType(ItemClass)) Then
        Dim originalItem As ItemClass = e.Data.GetData(GetType(ItemClass))
        Dim targetItem As ItemClass = SftTree1.DropTarget
        Dim newItem As ItemClass = Nothing
        If e.Effect = DragDropEffects.Move Then
            Try
                newItem = originalItem.Move(targetItem, MoveStyleEnum.TargetAsParentInsertFirst)
            Catch exc As Exception
                MessageBox.Show(exc.Message)
            End Try
        Else
            Try
                newItem = originalItem.Copy(targetItem, CopyStyleEnum.TargetAsParentInsertFirst, True)
            Catch exc As Exception

See Also ItemClass Class | Classes | SftTree/NET 2.0



Spring Break!

Our offices will be closed this week (March 18 through March 22).

We'll be back March 24 to address any pending sales and support issues.