本文整理汇总了VB.NET中System.Windows.Forms.DataFormats类的典型用法代码示例。如果您正苦于以下问题:VB.NET DataFormats类的具体用法?VB.NET DataFormats怎么用?VB.NET DataFormats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataFormats类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyClass1
Option Explicit
Option Strict
Imports System.Windows.Forms
Public Class MyClass1
Inherits Form
Private textBox1 As TextBox
Public Sub MyClipboardMethod()
' Creates a new data format.
Dim myFormat As DataFormats.Format = _
DataFormats.GetFormat("myFormat")
' Creates a new object and store it in a DataObject using myFormat
' as the type of format.
Dim myObject As New MyNewObject()
Dim myDataObject As New DataObject(myFormat.Name, myObject)
' Copies myObject into the clipboard.
Clipboard.SetDataObject(myDataObject)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim myRetrievedObject As IDataObject = Clipboard.GetDataObject()
' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As MyNewObject = _
CType(myRetrievedObject.GetData(myFormat.Name), MyNewObject)
' Print the value of the Object in a textBox.
textBox1.Text = myDereferencedObject.MyObjectValue
End Sub
End Class
' Creates a new type.
<Serializable()> Public Class MyNewObject
Inherits Object
Private myValue As String
' Creates a default constructor for the class.
Public Sub New()
myValue = "This is the value of the class"
End Sub
' Creates a property to retrieve or set the value.
Public Property MyObjectValue() As String
Get
Return myValue
End Get
Set
myValue = value
End Set
End Property
End Class