本文整理匯總了VB.NET中System.Windows.Forms.IDataObject.SetData方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET IDataObject.SetData方法的具體用法?VB.NET IDataObject.SetData怎麽用?VB.NET IDataObject.SetData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了IDataObject.SetData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: DataObject
Private Sub SetData1()
' Creates a component to store in the data object.
Dim myComponent As New System.ComponentModel.Component()
' Creates a data object.
Dim myDataObject As New DataObject()
' Adds the component to the data object.
myDataObject.SetData(myComponent)
' Checks whether data of the specified type is in the data object.
Dim myType As Type = myComponent.GetType()
Dim myMessageText As String
If myDataObject.GetDataPresent(myType) Then
myMessageText = "Data of type " + myType.Name + " is present in the data object"
Else
myMessageText = "Data of type " + myType.Name + " is not present in the data object"
End If
' Displays the result in a message box.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
示例2: DataObject
Private Sub SetData2()
' Creates a data object.
Dim myDataObject As New DataObject()
' Stores a string, specifying the UnicodeText format.
myDataObject.SetData(DataFormats.UnicodeText, "Hello World!")
' Retrieves the data by specifying the Text format.
Dim myMessageText As String = "The data type is " & _
myDataObject.GetData(DataFormats.Text).GetType().Name
' Displays the result.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
示例3: DataObject
Private Sub SetData3()
' Creates a component.
Dim myComponent As New System.ComponentModel.Component()
' Gets the type of the component.
Dim myType As Type = myComponent.GetType()
' Creates a data object.
Dim myDataObject As New DataObject()
' Stores the component in the data object.
myDataObject.SetData(myType, myComponent)
' Checks whether data of the specified type is in the data object.
Dim myMessageText As String
If myDataObject.GetDataPresent(myType) Then
myMessageText = "Data of type " & myType.Name & " is stored in the data object"
Else
myMessageText = "No data of type " & myType.Name & " is stored in the data object"
End If
' Displays the result.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
示例4: DataObject
Private Sub SetData4()
' Creates a new data object.
Dim myDataObject As New DataObject()
' Adds UnicodeText string to the object, and set the autoConvert
' parameter to false.
myDataObject.SetData(DataFormats.UnicodeText, False, "My text string")
' Gets the data format(s) in the data object.
Dim arrayOfFormats As [String]() = myDataObject.GetFormats()
' Stores the results in a string.
Dim theResult As String = "The format(s) associated with the data are:" + _
ControlChars.Cr
Dim i As Integer
For i = 0 To arrayOfFormats.Length - 1
theResult += arrayOfFormats(i) + ControlChars.Cr
Next i
' Show the results in a message box.
MessageBox.Show(theResult)
End Sub