Intersoft.Client.UI.Controls.Interactivity Namespace > DragDropEventData Class : GetDataPresent Method |
Overload | Description |
---|---|
GetDataPresent(String) | Gets a value that indicates whether the data with specified format is present. |
GetDataPresent(Type) | Gets a value that indicates whether the data with specified format is present. |
GetDataPresent(String,Boolean) | Gets a value that indicates whether the data with specified format is present. |
Retrieving data from a data object in a particular format simply involves calling one of the GetData methods and specifying the desired data format. One of the GetDataPresent methods can be used to check for the presence of a particular data format. GetData returns the data in a Object; depending on the data format, this object can be cast to a type-specific container.
The following example code uses the GetDataPresent(String) overload to first check if a specified data format is available (natively or by auto-convert). If the specified format is available, the example retrieves the data by using the GetData(String) method.
GetData |
Copy Code
|
---|---|
string sourceData = "Some string data to store..."; byte[] unicodeText = Encoding.Unicode.GetBytes(sourceData); byte[] utf8Text = Encoding.UTF8.GetBytes(sourceData); string uniCodeFormat = "Unicode"; string utf8DataFormat = "UTF-8"; DragDropEventData dataObject = e.Data as DragDropEventData; dataObject.SetData(sourceData); dataObject.SetData(uniCodeFormat, unicodeText); dataObject.SetData(utf8DataFormat, utf8Text); string desiredFormat = uniCodeFormat; byte[] data = null; // Use the GetDataPresent method to check for the presence of a desired data format. // This particular overload of GetDataPresent looks for both native and auto-convertible // data formats. if (dataObject.GetDataPresent(desiredFormat)) { // If the desired data format is present, use one of the GetData methods to retrieve the // data from the data object. data = dataObject.GetData(desiredFormat) as byte[]; } |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2