RichTextBox.Paste(DataFormats+Format) Yöntem

Tanım

Pano içeriğini belirtilen Pano biçiminde yapıştırır.

public:
 void Paste(System::Windows::Forms::DataFormats::Format ^ clipFormat);
public void Paste (System.Windows.Forms.DataFormats.Format clipFormat);
override this.Paste : System.Windows.Forms.DataFormats.Format -> unit
Public Sub Paste (clipFormat As DataFormats.Format)

Parametreler

clipFormat
DataFormats.Format

Verilerin Pano'dan alınması gereken Pano biçimi.

Örnekler

Aşağıdaki kod örneği, denetime bit eşlem yapıştırmak için yönteminin RichTextBox nasıl kullanılacağını Paste gösterir. Dosyadan bir bit eşlem açtıktan sonra örnek, bit eşlemi Windows panoya kopyalamak için yöntemini kullanırSetDataObject. Son olarak, örnek nesnenin Bitmap biçimini alır, biçimin denetime RichTextBox yapıştırılabildiğini doğrular ve verileri yapıştırmak için yöntemini kullanır Paste .

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;
      }
   }
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 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

Açıklamalar

Panodaki verileri denetime yapıştırmak için bu yöntemi kullanabilirsiniz. Yöntemin Paste bu sürümü, belirtilen Pano biçiminde yalnızca metin yapıştırmanıza olanak sağladığından yönteminden TextBoxBase.Paste farklıdır. Pano içindeki CanPaste verilerin belirtilen Pano biçiminde olup olmadığını belirlemek için yöntemini kullanabilirsiniz. Ardından, yapıştırma işleminin Paste uygun veri biçimiyle yapıldığından emin olmak için yönteminin bu sürümünü çağırabilirsiniz.

Şunlara uygulanır

Ayrıca bkz.