Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

DropHighlight Property, SftTreeItems Object

Defines the index of the current drop target of a drag & drop operation.

Syntax

Get

VB.NETItemIndex = object.DropHighlight As Integer
VBItemIndex = object.DropHighlight As Long
C#.NETint ItemIndex = object.DropHighlight;
VC++long ItemIndex = object->DropHighlight;
long ItemIndex = object->GetDropHighlight();
CHRESULT object->get_DropHighlight(long* ItemIndex);

Put

VB.NETobject.DropHighlight = ItemIndex As Integer
VBobject.DropHighlight = ItemIndex As Long
C#.NETint object.DropHighlight = ItemIndex;
VC++long object->DropHighlight = ItemIndex;
void object->PutDropHighlight(long ItemIndex);
CHRESULT object->put_DropHighlight(long ItemIndex);

object

A SftTreeItems object.

ItemIndex

Defines the index of the current drop target of a drag & drop operation. This value can be -1 to clear the drop target.

Comments

The DropHighlight property defines the index of the current drop target of a drag & drop operation.

The DropHighlight property is used to highlight the target of a drag & drop operation. There can be only one drop target at any one time. By setting the DropHighlight property to a new item, the previous item is no longer a drop target and is no longer highlighted.

The Items.DropHighlightStyle property can be used to control the appearance of the target item. Depending on the Items.DropHighlightStyle property value, the ItemIndex specified is the actual drop target or the insertion point. If used as an insertion point, the ItemIndex value can be set to the number of items in the tree control, which moves the insertion point to the end of the list of items.

By setting the DropHighlight property to -1, the current drop target is cleared.

A drag & drop operation always starts at the current location described by the Items.Current property. It is the application's responsibility to visually implement the drag & drop operation. When the operation involves the current tree control, this is accomplished by using the Items.HitTest method and the Items.DropHighlight property. If dragging to another tree control, the target tree control's Items.HitTest method and Items.DropHighlight property have to be used. If dragging to another control type (list box, edit control, etc.), other means may have to be used as implemented by the target control.

Once a drag & drop operation ends, the DropHighlight property has to be cleared by setting ItemIndex to -1. This removes the highlight indicator from the target item.

If the DropHighlight property is set to the first (or last) item currently visible in the tree control's client area, the tree control automatically scrolls up (or down) one item. This allows a user to drag items to a target item which has to be scrolled into view first. The contents of the tree control will scroll in the given direction until the DropHighlight property is set to -1 or to the index of an item which is not the first (or last) item visible.

The Items.SelectStyle and Items.NoFocusStyle properties work in conjunction with the Items.OutlineStyle property to determine the exact appearance of drop target items. The highlighted portion of a drop target is rendered using the outline style defined by the Items.OutlineStyle property.

Examples

VB.NET

    Private Sub AxSftTree1_OLEDragDrop(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_OLEDragDropEvent) Handles AxSftTree1.OLEDragDrop
        ' get horizontal extent and width of column 0
        Dim horzExtent As Integer
        horzExtent = AxSftTree1.Items.HorizontalExtentPix
        Dim firstColumnWidth As Integer
        firstColumnWidth = AxSftTree1.get_Column(0).WidthPix

        Dim insertAt As Integer
        insertAt = AxSftTree1.Items.DropHighlight
        If insertAt < 0 Then Exit Sub
        If e.data.GetFormat(SftOLEClipboardConstants.sftCFText) Then
            Dim lvl As Integer
            lvl = AxSftTree1.get_Item(insertAt).Level
            Dim str As String
            str = e.data.GetData(SftOLEClipboardConstants.sftCFText)
            Dim newItem As Integer

VB6

    Dim str As String
    Dim lvl As Integer, newItem As Integer
    Dim horzExtent As Single, col0Width As Single

    ' get horizontal extent and width of column 0
    horzExtent = SftTree1.Items.HorizontalExtent
    col0Width = SftTree1.Column(0).Width

    insertAt = SftTree1.Items.DropHighlight
    If insertAt < 0 Then Exit Sub

    If Data.GetFormat(vbCFText) Then
        lvl = SftTree1.Item(insertAt).Level
        str = Data.GetData(vbCFText)
        newItem = SftTree1.Items.Insert(insertAt + 1, str)
        SftTree1.Item(newItem).Level = lvl + 1

C#

        }

        private void axSftTree1_OLEDragDrop(object sender, AxSftTreeLib75._DSftTreeEvents_OLEDragDropEvent e) {

            // get horizontal extent and width of column 0
            int horzExtent = axSftTree1.Items.HorizontalExtentPix;
            int firstColumnWidth = axSftTree1.get_Column(0).WidthPix;

            int insertAt = axSftTree1.Items.DropHighlight;
            if (insertAt < 0) return;
            if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFText)) {
                short lvl = axSftTree1.get_Item(insertAt).Level;
                string str = (string) e.data.GetData(SftOLEClipboardConstants.sftCFText);
                int newItem = axSftTree1.Items.Insert(insertAt + 1, str);
                axSftTree1.get_Item(newItem).Level = (short) (lvl + 1);
            }

C++

    i = m_vTree->Items->Add(_bstr_t(_T("Item 1")));
     m_vTree->Item[i]->Level = 1;
    i = m_vTree->Items->Add(_bstr_t(_T("Item 2")));
     m_vTree->Item[i]->Level = 2;
    i = m_vTree->Items->Add(_bstr_t(_T("Item 3")));
     m_vTree->Item[i]->Level = 1;


    m_textDropTarget.Register(&m_DropTarget); // register as a drop target

    return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

See Also SftTreeItems Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.


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.