Name

IDataObject.GetData Method

Class

System.Windows.Forms.IDataObject

Syntax

GetData(format [,autoconvert])
format (required; String or Type object)

Field member of the DataFormats class (see later for more information on this) or a Type object representing the format of the data

autoconvert (optional; Boolean)

True to convert the data to the specified format

Return value

An Object that contains Clipboard data in the specified format

Description

Retrieves the data of the given format, optionally converting the data format

Rules at a Glance

  • The format argument can be one of the following string values:

    DataFormats.Bitmap
    DataFormats.CommaSeparatedValue
    DataFormats.Dib
    DataFormats.Dif
    DataFormats.EnhancedMetafile
    DataFormats.FileDrop
    DataFormats.Html
    DataFormats.Locale
    DataFormats.MetafilePict
    DataFormats.OemText
    DataFormats.Palette
    DataFormats.PenData
    DataFormats.Riff
    DataFormats.Rtf
    DataFormats.Serializable (a format that encapsulates any type of Windows Forms object)
    DataFormats.StringFormat
    DataFormats.SymbolicLink
    DataFormats.Text
    DataFormats.Tiff
    DataFormats.UnicodeText
    DataFormats.WaveAudio
  • If format is a string, the autoconvert argument can be supplied in the method call.

  • If the GetData method cannot find data in format, it attempts to convert the data to format. If the data cannot be converted to the format, or if the data was stored with autoconvert set to False, the method returns Nothing.

Example

The following example extracts the text that is currently on the Clipboard:

' Declare ...

Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.