次の方法で共有


DataFormats.StringFormat フィールド

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

Public Shared ReadOnly StringFormat As String
[C#]
public static readonly string StringFormat;
[C++]
public: static String* StringFormat;
[JScript]
public static var StringFormat : String;

解説

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

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

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

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

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

使用例

 
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 'Main 
End Class 'DataFormats_StringFormat

[C#] 
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);
}


[C++] 
try {
    String*  myString = S"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 = dynamic_cast<String*>(myDataObject->GetData(DataFormats::StringFormat));
        Console::WriteLine(clipString);
    } else {
        Console::WriteLine(S"No String information was contained in the clipboard.");
    }
} catch (Exception* e) {
    Console::WriteLine(e->Message);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataFormats クラス | DataFormats メンバ | System.Windows.Forms 名前空間 | GetData | SetData | GetDataPresent | GetFormats | DataObject | IDataObject | GetFormat | Format.name | Format.id