Drag and Drop using DaDObject Example

See Also

In this example, one or more MDBTree nodes are dragged and dropped onto the example form in all available formats

Create a new Visual Basic project. Add the PI-MDBTree Control component to the project, and add a reference to the PISDK Type Library. Drop a PI-MDBTree  control onto a new form. Size the control so that it can show few tree nodes. Add three (3) standard textboxes and make them fairly large. Change the following properties for all the textboxes:

- OLEDropMode -> manual

- MultiLine = True

Paste the code into the Declarations section. Run the project. The form should come up with a single tree node for the default server (make sure that that default server is available). Expand the tree (modules-branch) few levels down and then drag/drop a module onto textbox Text1. The text for the three textboxes should now be as follows: Text1 = name of the module, Text2 = full pathname of the module, Text3 = persistence string of the module. You can also drag multiple nodes at a time (keep CTRL key down while selecting).

' OLE Drop - Use the given Data object to access the clipboard. It seems that the data is not there
' anymore (Data object propably cleared it?)
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim DragDropObj As New MDBTreeCtl.DaDObject ' create temporary object

    Text1.Text = Data.GetData(vbCFText)                 ' plain object names from the Data object as text
    If Data.GetFormat(DragDropObj.PathNamesClipboardFormat) Then         ' See if pathnames present
        Text2.Text = Data.GetData(DragDropObj.PathNamesClipboardFormat)     ' and get them
    End If
    If Data.GetFormat(DragDropObj.PersistenceClipboardFormat) Then '     See if persistence strings  present
        Text3.Text = Data.GetData(DragDropObj.PersistenceClipboardFormat) ' and get..
    End If
End Sub

Enabling Operational Intelligence