DataObject.SetData Method

Definition

Stores the specified data in this data object.

Overloads

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(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.

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(Object)

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

public:
 virtual void SetData(System::Object ^ data);
[System.Security.SecurityCritical]
public void SetData (object data);
public void SetData (object data);
[<System.Security.SecurityCritical>]
abstract member SetData : obj -> unit
override this.SetData : obj -> unit
abstract member SetData : obj -> unit
override this.SetData : obj -> unit
Public Sub SetData (data As Object)

Parameters

data
Object

An object that represents the data to store in this data object.

Implements

Attributes

Exceptions

data is null.

Remarks

This method adds data with auto-conversion enabled (the same as calling SetData(String, Object, Boolean) with autoConvert set to true).

Applies to

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.

public:
 virtual void SetData(System::String ^ format, System::Object ^ data);
[System.Security.SecurityCritical]
public void SetData (string format, object data);
public void SetData (string format, object data);
[<System.Security.SecurityCritical>]
abstract member SetData : string * obj -> unit
override this.SetData : string * obj -> unit
abstract member SetData : string * obj -> unit
override this.SetData : string * obj -> unit
Public Sub SetData (format As String, data As Object)

Parameters

format
String

A string that specifies the format for the data. For a set of predefined data formats, see the DataFormats class.

data
Object

An object that represents the data to store in this data object.

Implements

Attributes

Exceptions

data or format is null.

Remarks

This method adds data with auto-conversion enabled (the same as calling SetData(String, Object, Boolean) with autoConvert set to true).

Applies to

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.

public:
 virtual void SetData(Type ^ format, System::Object ^ data);
[System.Security.SecurityCritical]
public void SetData (Type format, object data);
public void SetData (Type format, object data);
[<System.Security.SecurityCritical>]
abstract member SetData : Type * obj -> unit
override this.SetData : Type * obj -> unit
abstract member SetData : Type * obj -> unit
override this.SetData : Type * obj -> unit
Public Sub SetData (format As Type, data As Object)

Parameters

format
Type

A Type object that specifies the format for the data. For a set of predefined data formats, see the DataFormats class.

data
Object

An object that represents the data to store in this data object.

Implements

Attributes

Exceptions

data or format is null.

Remarks

This method adds data with auto-conversion enabled (the same as calling SetData(String, Object, Boolean) with autoConvert set to true).

Applies to

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.

public:
 virtual void SetData(System::String ^ format, System::Object ^ data, bool autoConvert);
[System.Security.SecurityCritical]
public void SetData (string format, object data, bool autoConvert);
public void SetData (string format, object data, bool autoConvert);
[<System.Security.SecurityCritical>]
abstract member SetData : string * obj * bool -> unit
override this.SetData : string * obj * bool -> unit
abstract member SetData : string * obj * bool -> unit
override this.SetData : string * obj * bool -> unit
Public Sub SetData (format As String, data As Object, autoConvert As Boolean)

Parameters

format
String

A string that specifies the format for the data. For a set of predefined data formats, see the DataFormats class.

data
Object

An object that represents the data to store in this data object.

autoConvert
Boolean

true to allow the data to be converted to another format on retrieval; false to prohibit the data from being converted to another format on retrieval.

Implements

Attributes

Exceptions

data or format is null.

Applies to