RichTextBox.CanPaste メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RichTextBox.CanPaste メソッドの意味・解説 

RichTextBox.CanPaste メソッド

クリップボード情報指定したデータ形式貼り付けできるかどうか確認します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function CanPaste ( _
    clipFormat As Format _
) As Boolean
Dim instance As RichTextBox
Dim clipFormat As Format
Dim returnValue As Boolean

returnValue = instance.CanPaste(clipFormat)
public bool CanPaste (
    Format clipFormat
)
public:
bool CanPaste (
    Format^ clipFormat
)
public boolean CanPaste (
    Format clipFormat
)
public function CanPaste (
    clipFormat : Format
) : boolean

パラメータ

clipFormat

System.Windows.Forms.DataFormats.Format 値の 1 つ

戻り値
クリップボードデータ指定したデータ形式貼り付けできる場合trueそれ以外場合false

解説解説
使用例使用例

Paste メソッド使用してビットマップRichTextBox コントロール貼り付ける方法次のコード例示しますファイルかビットマップ開いた後、この例では SetDataObject メソッド使用して Windows クリップボードビットマップコピーします最後にBitmap オブジェクト書式取得しCanPaste メソッド使用してその書式RichTextBox コントロール貼り付けられることを検証してから、Paste メソッド使用してデータ貼り付けます。

Private Function PasteMyBitmap(ByVal
 Filename As String) As
 Boolean

    'Open an bitmap from file and copy it to the clipboard.
    Dim MyBitmap As Bitmap
    MyBitmap = Bitmap.FromFile(Filename)

    ' Copy the bitmap to the clipboard.
    Clipboard.SetDataObject(MyBitmap)

    ' Get the format for the object type.
    Dim MyFormat As DataFormats.Format = DataFormats.GetFormat(DataFormats.Bitmap)

    ' After verifying that the data can be pasted, paste it.
    If RichTextBox1.CanPaste(MyFormat) Then

        RichTextBox1.Paste(MyFormat)
        PasteMyBitmap = True

    Else

        MessageBox.Show("The data format that you attempted to
 paste is not supported by this control.")
        PasteMyBitmap = False

    End If


End Function
private bool pasteMyBitmap(string
 fileName)
{

    // Open an bitmap from file and copy it to the clipboard.
    Bitmap myBitmap = new Bitmap(fileName);
            
    // Copy the bitmap to the clipboard.
    Clipboard.SetDataObject(myBitmap);

    // Get the format for the object type.
    DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);

    // After verifying that the data can be pasted, paste it.
    if(richTextBox1.CanPaste(myFormat))
    {
        richTextBox1.Paste(myFormat);
        return true;
    }
    else
    {
        MessageBox.Show("The data format that you attempted to paste is not
 supported by this control.");
        return false;
    }
}

private:
   bool pasteMyBitmap( String^ fileName )
   {
      // Open an bitmap from file and copy it to the clipboard.
      Bitmap^ myBitmap = gcnew Bitmap( fileName );

      // Copy the bitmap to the clipboard.
      Clipboard::SetDataObject( myBitmap );

      // Get the format for the object type.
      DataFormats::Format^ myFormat = DataFormats::GetFormat( DataFormats::Bitmap
 );

      // After verifying that the data can be pasted, paste it.
      if ( richTextBox1->CanPaste( myFormat ) )
      {
         richTextBox1->Paste( myFormat );
         return true;
      }
      else
      {
         MessageBox::Show( "The data format that you attempted to paste is not
 supported by this control." );
         return false;
      }
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からRichTextBox.CanPaste メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRichTextBox.CanPaste メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRichTextBox.CanPaste メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RichTextBox.CanPaste メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RichTextBox.CanPaste メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS