IDataObject.GetData Method |
System.Windows.Forms.IDataObject
GetData( format [, autoconvert ])
Field member of the DataFormats class (see later for more information on this) or a Type object representing the format of the data
True to convert the data to the specified format
An Object that contains Clipboard data in the specified format
Retrieves the data of the given format, optionally converting the data format
The format argument can be one of the following string values:
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 .
The following example extracts the text that is currently on the Clipboard:
' Declare IDataObject variable and get clipboard IDataObject Dim di As IDataObject = Clipboard.GetDataObject Dim obj As Object ' Call GetData method of IDataObject object to get clipboard data obj = di.GetData(DataFormats.Text, False) ' Show the text, if any If obj Is Nothing Then MsgBox("No text on clipboard.") Else MsgBox(CStr(obj)) End If
IDataObject.GetDataPresent Method, IDataObject.GetFormats Method