Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

Copy Method, ItemClass Class

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

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

Syntax

public ItemClass Copy(
    ItemCollectionClass ItemCollection,
    bool fDeep );
public ItemClass Copy(
    ItemClass ItemTarget,
    CopyStyleEnum Style,
    bool fDeep );
Public Function Copy(
    ByVal ItemCollection As ItemCollectionClass,
    ByVal fDeep As Boolean
  ) As ItemClass
Public Function Copy(
    ByVal ItemTarget As ItemClass,
    ByVal Style As CopyStyleEnum,
    ByVal fDeep As Boolean
  ) As ItemClass

Parameters

ItemCollection

The item collection.

fDeep

Defines whether child items are also copied. True to copy all child items, otherwise False.

ItemTarget

Specifies the target item, where the new item is to be copied to.

Style

Defines how the item is copied.

Return Value

The new item.

Comments

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

The newly inserted item is no longer selected.

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

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

Examples

C#

                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) {
                        MessageBox.Show(exc.Message);
                    }
                }
                if (newItem != null) {
                    sftTree1.Columns.MakeOptimal(0, false);
                    newItem.ScrollIntoView();

VB.NET

        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
                MessageBox.Show(exc.Message)
            End Try
        End If
        If Not newItem Is Nothing Then
            SftTree1.Columns.MakeOptimal(0, False)
            newItem.ScrollIntoView()

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.