IDataObject IDataObject IDataObject IDataObject Interface

定义

为传送数据提供与格式无关的机制。Provides a format-independent mechanism for transferring data.

public interface class IDataObject
[System.Runtime.InteropServices.ComVisible(true)]
public interface IDataObject
type IDataObject = interface
Public Interface IDataObject
派生
属性

注解

接口由Clipboard类和拖放操作使用。 IDataObjectThe IDataObject interface is used by the Clipboard class and in drag-and-drop operations.

在类中实现时, IDataObject方法允许用户在类的实例中以多种格式存储数据。When implemented in a class, the IDataObject methods allow the user to store data in multiple formats in an instance of the class. 以多种格式存储数据会增加目标应用程序 (其格式要求您可能不知道) 可以检索存储的数据的可能性。Storing data in more than one format increases the chance that a target application, whose format requirements you might not know, can retrieve the stored data. 若要在实例IDataObject中存储数据, 请SetData调用方法, 并在format参数中指定数据格式。To store data in an instance of IDataObject, call the SetData method and specify the data format in the format parameter. 如果您不希望false将存储的数据转换为另一种格式, 请将参数设置为。autoConvertSet the autoConvert parameter to false if you do not want stored data to be converted to another format when it is retrieved. SetData 一个IDataObject实例上调用多次以以多种格式存储数据。Invoke SetData multiple times on one instance of IDataObject to store data in more than one format.

通过调用方法并在format参数中指定数据格式, 可以从中检索存储的数据。 GetData IDataObjectYou retrieve stored data from an IDataObject by calling the GetData method and specifying the data format in the format parameter. 将参数设置为false , 以仅检索以指定格式存储的数据。 autoConvertSet the autoConvert parameter to false to retrieve only data that was stored in the specified format. 若要将存储的数据转换为指定的格式autoConvert , true请将设置为, autoConvert否则不使用。To convert the stored data to the specified format, set autoConvert to true, or do not use autoConvert.

若要确定存储在中IDataObject的数据的格式, 请使用以下IDataObject方法。To determine the formats of the data stored in an IDataObject, use the following IDataObject methods.

  • GetFormats调用方法以检索数据可用的所有格式的数组。Call the GetFormats method to retrieve an array of all the formats in which the data is available. 将参数设置为false , 以仅获取存储数据的格式。 autoConvertSet the autoConvert parameter to false to get only the formats in which the data is stored. 若要获取数据可用的所有格式, 请将设置autoConverttrue, 或者不要使用此参数。To get all the formats in which the data is available, set autoConvert to true, or do not use this parameter.

  • GetDataPresent调用方法以确定存储的数据是否以特定格式提供。Call the GetDataPresent method to determine whether stored data is available in a certain format. 如果你不希望将存储的数据转换为指定的格式, 请将autoConvert参数设置为。 falseIf you do not want stored data to be converted to the specified format, set the autoConvert parameter to false.

有关此接口的实现, 请参见类。DataObjectSee the DataObject class for an implementation of this interface. 请参阅用于预定义Clipboard数据格式的类。DataFormatsSee the DataFormats class for the predefined Clipboard data formats.

方法

GetData(String) GetData(String) GetData(String) GetData(String)

检索与指定的数据格式关联的数据。Retrieves the data associated with the specified data format.

GetData(Type) GetData(Type) GetData(Type) GetData(Type)

检索与指定的类类型格式关联的数据。Retrieves the data associated with the specified class type format.

GetData(String, Boolean) GetData(String, Boolean) GetData(String, Boolean) GetData(String, Boolean)

检索与指定数据格式相关联的数据,并使用一个布尔值确定是否将数据转换成该格式。Retrieves the data associated with the specified data format, using a Boolean to determine whether to convert the data to the format.

GetDataPresent(String) GetDataPresent(String) GetDataPresent(String) GetDataPresent(String)

确定此实例中存储的数据是否与指定的格式关联,或是否可以转换成指定的格式。Determines whether data stored in this instance is associated with, or can be converted to, the specified format.

GetDataPresent(Type) GetDataPresent(Type) GetDataPresent(Type) GetDataPresent(Type)

确定此实例中存储的数据是否与指定的格式关联,或是否可以转换成指定的格式。Determines whether data stored in this instance is associated with, or can be converted to, the specified format.

GetDataPresent(String, Boolean) GetDataPresent(String, Boolean) GetDataPresent(String, Boolean) GetDataPresent(String, Boolean)

确定该实例中存储的数据是否与指定格式关联,同时使用一个布尔值确定是否将数据转换成此格式。Determines whether data stored in this instance is associated with the specified format, using a Boolean value to determine whether to convert the data to the format.

GetFormats() GetFormats() GetFormats() GetFormats()

返回存储在此实例中的数据所关联的或可以转换为的所有格式的列表。Returns a list of all formats that data stored in this instance is associated with or can be converted to.

GetFormats(Boolean) GetFormats(Boolean) GetFormats(Boolean) GetFormats(Boolean)

获取该实例中存储的数据所关联或可转换到的所有格式的列表,同时使用一个布尔值确定是检索数据可转换到的所有格式,还是只检索本机数据格式。Gets a list of all formats that data stored in this instance is associated with or can be converted to, using a Boolean value to determine whether to retrieve all formats that the data can be converted to or only native data formats.

SetData(Object) SetData(Object) SetData(Object) SetData(Object)

使用此格式的数据类存储此实例中的指定数据。Stores the specified data in this instance, using the class of the data for the format.

SetData(String, Object) SetData(String, Object) SetData(String, Object) SetData(String, Object)

存储此实例中的指定数据及其关联格式。Stores the specified data and its associated format in this instance.

SetData(Type, Object) SetData(Type, Object) SetData(Type, Object) SetData(Type, Object)

存储此实例中的指定数据及其关联类类型。Stores the specified data and its associated class type in this instance.

SetData(String, Boolean, Object) SetData(String, Boolean, Object) SetData(String, Boolean, Object) SetData(String, Boolean, Object)

在该实例中存储指定的数据及其关联格式,同时使用一个布尔值指定数据能否转换成另一格式。Stores the specified data and its associated format in this instance, using a Boolean value to specify whether the data can be converted to another format.

适用于

另请参阅