DataFormats.StringFormat フィールド

定義

Windows フォーム文字列クラス形式を指定します。Windows フォームは、この形式を使用して文字列オブジェクトを格納します。 static フィールドは読み取り専用です。

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

フィールド値

次のコード例では、このメンバーの使用方法を示します。

try
{
   String^ myString = "This is a String from the ClipBoard";
   // Sets the data to the Clipboard.   
   Clipboard::SetDataObject( myString );
   IDataObject^ myDataObject = Clipboard::GetDataObject();
   
   // Checks whether the data is present or not in the Clipboard.
   if ( myDataObject->GetDataPresent( DataFormats::StringFormat ) )
   {
      String^ clipString = (String^)(myDataObject->GetData( DataFormats::StringFormat ));
      Console::WriteLine( clipString );
   }
   else
   {
      Console::WriteLine( "No String information was contained in the clipboard." );
   }
}
catch ( Exception^ e ) 
{
   Console::WriteLine( e->Message );
}
try
{
    String myString = "This is a String from the ClipBoard";
    // Sets the data to the Clipboard.   
    Clipboard.SetDataObject(myString);
    IDataObject myDataObject = Clipboard.GetDataObject();

    // Checks whether the data is present or not in the Clipboard.
    if(myDataObject.GetDataPresent(DataFormats.StringFormat)) 
    {
        String clipString = (String)myDataObject.GetData(DataFormats.StringFormat);
        Console.WriteLine(clipString);
    } 
    else 
    {
        Console.WriteLine("No String information was contained in the clipboard.");
    }
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
}
        Try
            Dim myString As String = "This is a String from the ClipBoard"
            ' Sets the data to the Clipboard.   
            Clipboard.SetDataObject(myString)
            Dim myDataObject As IDataObject = Clipboard.GetDataObject()
          
            ' Checks whether the data is present or not in the Clipboard.
            If myDataObject.GetDataPresent(DataFormats.StringFormat) Then
                Dim clipString As String = CType(myDataObject.GetData(DataFormats.StringFormat), String)
                Console.WriteLine(clipString)
            Else
                Console.WriteLine("No String information was contained in the clipboard.")
            End If
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
   End Sub
End Class

注釈

このフィールドは、インターフェイスと DataObject クラスによってIDataObject使用され、データ型を指定します。

または を IDataObjectDataObject実装に追加する場合は、 メソッドと DataObject.SetData メソッドの形式としてこのフィールドをIDataObject.SetData使用します。

この型のオブジェクトが存在するかどうかを確認するには、 メソッドと DataObject.GetDataPresent メソッドの形式としてこのフィールドをIDataObject.GetDataPresent使用します。

この型のオブジェクトを取得するには、 メソッドと DataObject.GetData メソッドの形式IDataObject.GetDataとしてこれを使用します。

注意

文字列クラスの形式はWindows フォームのみに固有であり、Windows フォームの外部で作成されたアプリケーションでは認識されません。

適用対象

こちらもご覧ください