Skip to content

DragText Property

Description

The DragText property holds the text that will be sent to the Target Component when the item is dropped.

Property Type

Read-write property

Syntax (Visual Basic)

Public Property DragText() As String

Remarks

By default, an XML string that contains the Caption, Id, IconIndex, Tag, and Selected state of the item will be sent to the Target Component if the DragText property is not set. If the DragText is set, then the text contained in DragText will be sent to the Target Component instead of the XML string.

Note that the XML string will contain an additional parameter name CompactMode that is used internally and can be ignored. Also, the Tag parameter is only included if the Tag property has been set for the item.

The text sent to the Target Component will be in the vbCFText format. The text will be sent as a DataObject to the Target Component's OLEDrag (OLEDragDrop, OLEDragOver, etc.) events. You must then use the GetData method of the DataObject to get the text.

Example

Custom Drag and Drop Item Data (Visual Basic)

This sample illustrates how to set the text string that will be passed to the Target Component when the TaskPanelGroupItem is dropped onto another control outside of the TaskPanel.

Note: This sample assumes there is a PictureBox control named 'pboxDragAndDrop'.

'=====================================================  
' General Code Section  
'=====================================================  

' IDs For the Group And Group Item objects  
Const ID_GROUP_GENERAL = 100  
Const ID_GROUP_COMPONENTS = 101  
Const ID_ITEM_PICBOX = 120  
Const ID_ITEM_TXTBOX = 121  
Const ID_ITEM_LSTCTRL = 122  

'=====================================================  
' Form_Load Event  
'=====================================================  

Private Sub Form_Load()  
    Dim Group As TaskPanelGroup, Item As TaskPanelGroupItem  

    ' Add a group to the toolbox  
    Set Group = wndToolBox.Groups.Add(ID_GROUP_GENERAL, "General")  
        ' Adds an item to the "General" group  
        Set Item = Group.Items.Add(ID_ITEM_PICBOX, "PictureBox", xtpTaskItemTypeLink, ID_ITEM_PICBOX)  
        ' Sets the text that will be sent to the Target Component when the item is dragged and  
        ' dropped onto another control outside the TaskPanel  
        Item.DragText = "Picture Box Control"  

        ' Adds an item to the "General" group  
        Set Item = Group.Items.Add(ID_ITEM_TXTBOX, "TextBox", xtpTaskItemTypeLink, ID_ITEM_TXTBOX)  
        ' Sets the text that will be sent to the Target Component when the item is dragged and  
        ' dropped onto another control outside the TaskPanel  
        Item.DragText = "Text Box Control"  

    ' Add a group to the toolbox  
    Set Group = wndToolBox.Groups.Add(ID_GROUP_COMPONENTS, "Components")  
        ' Adds an item to the "Components" group  
        Set Item = Group.Items.Add(ID_ITEM_LSTCTRL, "ListBox", xtpTaskItemTypeLink, ID_ITEM_LSTCTRL)  
        Item.Tag = "Additional Text"  
        ' Note that the DrawText property was not set for this item, this will cause the Target Component  
        ' to receive the following Default text:  

    ' Specifies the Drag and Drop options for the entire Task Panel  
    wndToolBox.AllowDrag = xtpTaskItemAllowDrag  
End Sub  

'=====================================================  
' PictureBox OLEDragDrop Event  
'=====================================================  

Private Sub pboxDragAndDrop_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)  
    If Data.GetFormat(vbCFText) Then  
        Dim strItem As String  

        ' Converts the data stored in the DataObject into a String  
        ' This will contain the text from the DrawText property of the  
        ' dropped item if the property was set, otherwise the default  
        ' XML string will be used.  
        strItem = Data.GetData(vbCFText)  

        ' Displays the text of the item that was dropped  
        MsgBox ("Dropped " & strItem)  
    End If  
End Sub  

'=====================================================  
' PictureBox OLEDragOver Event  
'=====================================================  

Private Sub pboxDragAndDrop_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)  
    ' Specifies that only text objects can be dropped into  
    ' the picture box control.  
    If Not Data.GetFormat(vbCFText) Then  
       Effect = vbDropEffectNone  
    End If  
End Sub  

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.