DataFormats.Text フィールド

定義

標準 ANSI テキスト形式を指定します。Specifies the standard ANSI text format. static フィールドは読み取り専用です。This static field is read-only.

public: static initonly System::String ^ Text;
public static readonly string Text;
 staticval mutable Text : string
Public Shared ReadOnly Text 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.

IDataObject または DataObjectの実装に追加する場合は、このフィールドを IDataObject.SetData および DataObject.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.GetDataPresent および DataObject.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.GetData および DataObject.GetData メソッドの形式として使用します。To get an object of this type, use this as the format for the IDataObject.GetData and DataObject.GetData methods.

適用対象

こちらもご覧ください