ערוך

שתף באמצעות


DataObject Class

Definition

Provides a basic implementation of the IDataObject interface, which defines a format-independent mechanism for transferring data.

public ref class DataObject sealed : System::Runtime::InteropServices::ComTypes::IDataObject, System::Windows::IDataObject
public sealed class DataObject : System.Runtime.InteropServices.ComTypes.IDataObject, System.Windows.IDataObject
type DataObject = class
    interface IDataObject
    interface IDataObject
Public NotInheritable Class DataObject
Implements IDataObject, IDataObject
Inheritance
DataObject
Implements

Examples

The following example shows how to use this class.

string stringData = "Some string data to store...";
string dataFormat = DataFormats.UnicodeText;
DataObject dataObject = new DataObject(dataFormat, stringData);
Dim stringData As String = "Some string data to store..."
Dim dataFormat As String = DataFormats.UnicodeText
Dim dataObject As New DataObject(dataFormat, stringData)

Remarks

Important

Calling methods from this class with untrusted data is a security risk. Call the methods from this class only with trusted data. For more information, see Validate All Inputs.

Constructors

DataObject()

Initializes a new instance of the DataObject class.

DataObject(Object)

Initializes a new instance of the DataObject class that contains the specified data.

DataObject(String, Object)

Initializes a new instance of the DataObject class that contains the specified data and its associated format; the format is specified by a string.

DataObject(String, Object, Boolean)

Initializes a new instance of the DataObject class that contains the specified data and its associated format; the format is specified by a string. This overload includes a Boolean flag to indicate whether the data may be converted to another format on retrieval.

DataObject(Type, Object)

Initializes a new instance of the DataObject class that contains the specified data and its associated format; the data format is specified by a Type object.

Fields

CopyingEvent

Identifies the Copying attached event.

PastingEvent

Identifies the Pasting attached event.

SettingDataEvent

Identifies the SettingData attached event.

Methods

AddCopyingHandler(DependencyObject, DataObjectCopyingEventHandler)

Adds a Copying event handler to a specified dependency object.

AddPastingHandler(DependencyObject, DataObjectPastingEventHandler)

Adds a Pasting event handler to a specified dependency object.

AddSettingDataHandler(DependencyObject, DataObjectSettingDataEventHandler)

Adds a SettingData event handler to a specified dependency object.

ContainsAudio()

Queries a data object for the presence of data in the WaveAudio data format.

ContainsFileDropList()

Queries a data object for the presence of data in the FileDrop data format.

ContainsImage()

Queries a data object for the presence of data in the Bitmap data format.

ContainsText()

Queries a data object for the presence of data in the UnicodeText format.

ContainsText(TextDataFormat)

Queries a data object for the presence of data in a text data format.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAudioStream()

Returns a stream that contains data in the WaveAudio data format.

GetData(String)

Returns data in a format specified by a string.

GetData(String, Boolean)

Returns a data object in a specified format, optionally converting the data to the specified format.

GetData(Type)

Returns a data object in a format specified by a Type object.

GetDataPresent(String)

Determines whether the data is available in, or can be converted to, a format specified by a string.

GetDataPresent(String, Boolean)

Determines whether the data is available in, or can be converted to, a specified format. A Boolean flag indicates whether to check if the data can be converted to the specified format if it is not available in that format.

GetDataPresent(Type)

Determines whether the data is available in, or can be converted to, a format specified by a Type object.

GetFileDropList()

Returns a string collection that contains a list of dropped files.

GetFormats()

Returns a list of formats in which the data in this data object is stored, or can be converted to.

GetFormats(Boolean)

Returns a list of formats in which the data in this data object is stored. A Boolean flag indicates whether to also include formats that the data can be automatically converted to.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetImage()

Returns a BitmapSource object that contains data in the Bitmap format.

GetText()

Returns a string that contains the UnicodeText data in this data object.

GetText(TextDataFormat)

Returns a string that contains text data of the specified format in this data object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemoveCopyingHandler(DependencyObject, DataObjectCopyingEventHandler)

Removes a Copying event handler from a specified dependency object.

RemovePastingHandler(DependencyObject, DataObjectPastingEventHandler)

Removes a Pasting event handler from a specified dependency object.

RemoveSettingDataHandler(DependencyObject, DataObjectSettingDataEventHandler)

Removes a SettingData event handler from a specified dependency object.

SetAudio(Byte[])

Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a byte array.

SetAudio(Stream)

Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a stream.

SetData(Object)

Stores the specified data in this data object, automatically determining the data format from the source object type.

SetData(String, Object)

Stores the specified data in this data object, along with one or more specified data formats; the data format is specified by a string.

SetData(String, Object, Boolean)

Stores the specified data in this data object, along with one or more specified data formats. This overload includes a Boolean flag to indicate whether the data can be converted to another format on retrieval.

SetData(Type, Object)

Stores the specified data in this data object, along with one or more specified data formats; the data format is specified by a Type object.

SetFileDropList(StringCollection)

Stores FileDrop data in this data object. The dropped file list is specified as a string collection.

SetImage(BitmapSource)

Stores Bitmap data in this data object. The image data is specified as a BitmapSource.

SetText(String)

Stores UnicodeText data, specified as a string, in this data object.

SetText(String, TextDataFormat)

Stores text data in this data object. The format of the text data to store is specified with a member of TextDataFormat.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Attached Events

Copying

Occurs when the associated dependency object has prepared appropriate data formats that represent the copy selection, added the copy selection formats to a DataObject, and is ready to either place the DataObject on the Clipboard or begin a drag-and-drop operation.

Pasting

Occurs when the associated dependency object is ready to paste data.

SettingData

Occurs when the associated dependency object attempts to add a new data format to a DataObject.

Explicit Interface Implementations

IDataObject.DAdvise(FORMATETC, ADVF, IAdviseSink, Int32)

Creates a connection between a data object and an advisory sink. This method is called by an object that supports an advisory sink and enables the advisory sink to be notified of changes in the object's data.

IDataObject.DUnadvise(Int32)

Destroys a notification connection that had been previously established.

IDataObject.EnumDAdvise(IEnumSTATDATA)

Creates an object that can be used to enumerate the current advisory connections.

IDataObject.EnumFormatEtc(DATADIR)

Creates an object for enumerating the FORMATETC structures for a data object. These structures are used in calls to GetData(FORMATETC, STGMEDIUM) or SetData(FORMATETC, STGMEDIUM, Boolean).

IDataObject.GetCanonicalFormatEtc(FORMATETC, FORMATETC)

Provides a standard FORMATETC structure that is logically equivalent to a more complex structure. Use this method to determine whether two different FORMATETC structures would return the same data, removing the need for duplicate rendering.

IDataObject.GetData(FORMATETC, STGMEDIUM)

Obtains data from a source data object. The GetData(FORMATETC, STGMEDIUM) method, which is called by a data consumer, renders the data described in the specified FORMATETC structure and transfers it through the specified STGMEDIUM structure. The caller then assumes responsibility for releasing the STGMEDIUM structure.

IDataObject.GetDataHere(FORMATETC, STGMEDIUM)

Obtains data from a source data object. This method, which is called by a data consumer, differs from the GetData(FORMATETC, STGMEDIUM) method in that the caller must allocate and free the specified storage medium.

IDataObject.QueryGetData(FORMATETC)

Determines whether the data object is capable of rendering the data described in the FORMATETC structure. Objects attempting a paste or drop operation can call this method before calling GetData(FORMATETC, STGMEDIUM) to get an indication of whether the operation may be successful.

IDataObject.SetData(FORMATETC, STGMEDIUM, Boolean)

Transfers data to the object that implements this method. This method is called by an object that contains a data source.

Applies to

See also