HeaderPane
Main
Hide

SftTree/OCX 8.0 - ActiveX Tree Control

Share Link
Print

GetData Method, DataObject Object

Retrieves data of a specified format from a DataObject object.

Syntax

VB.NETData = object.GetData([ ByVal Format As Object ] ) As Object
VBData = object.GetData([ ByVal Format As Variant ] ) As Variant
C#.NETobject Data = object.GetData(object Format);
VC++_variant_t Data = object->GetData(const _variant_t& Format = vtMissing);
CHRESULT object->raw_GetData(VARIANT Format, VARIANT* Data);

object

A DataObject object.

Format

The data format requested (see SftOLEClipboardConstants). The Format argument is optional. If Format is not specified, GetData returns data in a suitable format.

FormatValueDescription
sftCFText1Text (as a String value)
sftCFBitmap2Bitmap (as Picture object)
sftCFMetafile3Metafile (as Picture object)
sftCFDIB8Device independent bitmap (as Picture object)
sftCFFiles15List of files. The GetData method cannot be used to retrieve this format. Use the DataObject.Files collection instead.
sftCFRTF-16639Rich text format (as String value)

Data

Returns data of a specified format from a DataObject object.

Comments

The GetData method retrieves data of a specified format from a DataObject object.

It is possible for the GetData method and DataObject.SetData method to use data formats other than those listed as valid Format argument, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. The DataObject.SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified. The GetData method always returns data in a byte array when it is in a format that it doesn't recognize, although this may be transparently converted into other data types, such as strings. The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array. This allocation of memory is often larger than is actually required for the data. Therefore, there may be extraneous bytes near the end of the allocated memory segment.

Examples

VB.NET

            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub DropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DropTarget.DragDrop
        Dim arrayOfFormats As [String]() = e.Data.GetFormats(True) ' informational

        If e.Data.GetDataPresent(DataFormats.Text, True) Then
            DropTarget.Text = e.Data.GetData(DataFormats.Text, True)
        End If
        If e.Data.GetDataPresent(DataFormats.Bitmap, True) Then
            DropTargetPic.Image = e.Data.GetData(DataFormats.Bitmap, True)
        End If
    End Sub

    Private Sub DropTargetPic_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DropTargetPic.DragEnter

VB6

         .Item(i).Level = 2
        i = .Items.Add("Item 3")
         .Item(i).Level = 1
    End With
End Sub

Private Sub DropTarget_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    If Data.GetFormat(vbCFText) Then
        DropTarget.Caption = Data.GetData(vbCFText)
    End If
    If Data.GetFormat(vbCFDIB) Then
        Set DropTargetPic.Picture = Data.GetData(vbCFDIB)
    End If
End Sub

C#

                e.Effect = DragDropEffects.Copy;
            else
                e.Effect = DragDropEffects.None;
        }

        private void DropTarget_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
            String[] arrayOfFormats = e.Data.GetFormats(true); // informational
            if (e.Data.GetDataPresent(DataFormats.Text, true))
                DropTarget.Text = (string) e.Data.GetData(DataFormats.Text, true);
            if (e.Data.GetDataPresent(DataFormats.Bitmap, true))
                DropTargetPic.Image = (Image) e.Data.GetData(DataFormats.Bitmap, true);
        }

        private void DropTargetPic_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) {
            if (e.Data.GetDataPresent(DataFormats.Bitmap, true))
                e.Effect = DragDropEffects.Copy;

C++

    long horzExtent = m_vTree->Items->HorizontalExtentPix;
    long col0Width = m_vTree->Column[0]->WidthPix;

    long insertAt = m_vTree->Items->DropHighlight;
    if (insertAt < 0) return;

    if (pDataObject->GetFormat(sftCFText) != VARIANT_FALSE) {
        int lvl = m_vTree->Item[insertAt]->Level;
        _variant_t object = pDataObject->GetData((short)sftCFText);
        _bstr_t astring = object;
        long newItem = m_vTree->Items->Insert(insertAt + 1, astring);
        m_vTree->Item[newItem]->Level = lvl + 1;
    } else if (pDataObject->GetFormat(sftCFDIB)) {
        _variant_t object = pDataObject->GetData((short)sftCFDIB);
        IPictureDispPtr pPicDisp = object;
        m_vTree->Cell[insertAt][0]->Image->PutRefPicture(pPicDisp);

See Also DataObject Object | Object Hierarchy


Last Updated 05/24/2026 - (email)
© 2026 Softel vdm, Inc.