共用方式為


DataFormats.UnicodeText 欄位

定義

指定標準的 Windows Unicode 文字格式。 這個 static 欄位是唯讀的。

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

欄位值

範例

下列程式碼範例示範此成員的使用。

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

備註

介面和 DataObject 類別會使用此 IDataObject 欄位來指定資料類型。

將 新增至 IDataObject 或 的實 DataObject 作時,請使用此欄位做為 和 DataObject.SetData 方法的格式 IDataObject.SetData

若要查看此類型的物件是否存在,請使用此欄位做為 和 DataObject.GetDataPresent 方法的格式 IDataObject.GetDataPresent

若要取得此類型的 物件,請使用這個 做為 和 DataObject.GetData 方法的格式 IDataObject.GetData

適用於

另請參閱