DataFormats.UnicodeText 字段

定义

指定标准 Windows Unicode 文本格式。Specifies the standard Windows Unicode text format. static 字段是只读的。This static field is read-only.

public: static initonly System::String ^ UnicodeText;
public static readonly string UnicodeText;
 staticval mutable UnicodeText : string
Public Shared ReadOnly UnicodeText As String 

字段值

示例

下面的代码示例演示如何使用此成员。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 );
}
  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:"+clipString);
      }
  }
  catch(Exception e)
  {
      Console.WriteLine(e.Message);
  }


        Try
            Dim myString As String = "This is a String from the ClipBoard"
          
            ' Sets the data into the Clipboard.
            Clipboard.SetDataObject(myString)
            Dim myDataObject As IDataObject = Clipboard.GetDataObject()
            ' Checks whether the format of the data is 'UnicodeText' or not.
            If myDataObject.GetDataPresent(DataFormats.UnicodeText) Then
                Console.WriteLine($"Data in 'UnicodeText' format:{myDataObject.GetData(DataFormats.UnicodeText)}")
            Else
                Console.WriteLine("No String information was contained in the clipboard.")
            End If
          
            ' Checks whether the format of the data is 'Text' or not.
            If myDataObject.GetDataPresent(DataFormats.Text) Then
                Dim clipString As String = CType(myDataObject.GetData(DataFormats.StringFormat), String)
                Console.WriteLine($"Data in 'Text' format:{clipString}")
            End If
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub
End Class

注解

IDataObject 接口和 DataObject 类使用此字段来指定数据类型。This field is used by the IDataObject interface and the DataObject class to specify the data type.

添加到 IDataObjectDataObject的实现时,请将此字段用作 IDataObject.SetDataDataObject.SetData 方法的格式。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.

若要查看此类型的对象是否存在,请使用此字段作为 IDataObject.GetDataPresentDataObject.GetDataPresent 方法的格式。To see if an object of this type exists, use this field as the format for the IDataObject.GetDataPresent and DataObject.GetDataPresent methods.

若要获取此类型的对象,请使用此格式作为 IDataObject.GetDataDataObject.GetData 方法的格式。To get an object of this type, use this as the format for the IDataObject.GetData and DataObject.GetData methods.

适用于

另请参阅