SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
Defines the index of the current drop target of a drag & drop operation.
Get
VB.NET | ItemIndex = object.DropHighlight As Integer |
VB | ItemIndex = object.DropHighlight As Long |
C#.NET | int ItemIndex = object.DropHighlight; |
VC++ | long ItemIndex = object->DropHighlight; long ItemIndex = object->GetDropHighlight(); |
C | HRESULT object->get_DropHighlight(long* ItemIndex); |
Put
VB.NET | object.DropHighlight = ItemIndex As Integer |
VB | object.DropHighlight = ItemIndex As Long |
C#.NET | int object.DropHighlight = ItemIndex; |
VC++ | long object->DropHighlight = ItemIndex; void object->PutDropHighlight(long ItemIndex); |
C | HRESULT 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.
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.
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
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
} 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); }
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