DataFormats::Text Field

 

Specifies the standard ANSI text format. This static field is read-only.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
static initonly String^ Text

Field Value

Type: System::String^

This field is used by the IDataObject interface and the DataObject class to specify the data type.

When adding to an IDataObject or to an implementation of DataObject, use this field as the format for the IDataObject::SetData and DataObject::SetData methods.

To see if an object of this type exists, use this field as the format for the IDataObject::GetDataPresent and DataObject::GetDataPresent methods.

To get an object of this type, use this as the format for the IDataObject::GetData and DataObject::GetData methods.

The following code example demonstrates the use of this member.

try
{
   String^ myString = "This is a String from the ClipBoard";

   // Sets the data into the Clipboard.
   Clipboard::SetDataObject( myString );
   IDataObject^ myDataObject = Clipboard::GetDataObject();
   // Checks whether the format of the data is 'UnicodeText' or not.
   if ( myDataObject->GetDataPresent( DataFormats::UnicodeText ) )
   {
      Console::WriteLine( "Data in 'UnicodeText' format: " +
         myDataObject->GetData( DataFormats::UnicodeText ) );
   }
   else
   {
      Console::WriteLine( "No String information was contained in the clipboard." );
   }

   // Checks whether the format of the data is 'Text' or not.
   if ( myDataObject->GetDataPresent( DataFormats::Text ) )
   {
      String^ clipString = (String^)(myDataObject->GetData( DataFormats::StringFormat ));
      Console::WriteLine( "Data in 'Text' format: {0}", clipString );
   }
}
catch ( Exception^ e ) 
{
   Console::WriteLine( e->Message );
}

.NET Framework
Available since 1.1
Return to top
Show: