Clipboard.GetDataObject Method

   
Clipboard.GetDataObject Method

Class

System.Windows.Forms.Clipboard

Syntax

 Clipboard.GetDataObject(  ) 

Return value

An IDataObject object that represents the data currently on the clipboard

Description

Retrieves data from the Clipboard

Rules at a Glance

  • If the Clipboard contains no data, the GetDataObject method returns Nothing .

  • Once you have an IDataObject object, you can use the members of the IDataObject class to get information about the Clipboard data, as shown in the following example. The relevant IDataObject members for Clipboard manipulation in VB are GetData, GetDataPresent, and GetFormats.

Example

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 ' Fire 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 

VB.NET/VB 6 Differences

While the .NET Base Class Library uses the GetDataObject method to retrieve all data from the Clipboard, the Clipboard object in VB 6 included the GetFormat, GetData, and GetText methods to retrieve Clipboard data.

See Also

Clipboard Class, Clipboard.SetDataObject Method, IDataObject Interface

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net