Overload | Description |
---|---|
GetData() | Gets the data object. |
GetData(String) | Gets the data object. |
GetData(Type) | Gets the data object. |
GetData(String,Boolean) | Gets the data object. |
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 | ![]() |
---|---|
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[]; } |
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.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family