粘贴文字
string str="我写的东东";
Clipboard.SetDataObject(str);
IDataObject iData=System.Windows.Forms.Clipboard.GetDataObject();
if(iData.GetDataPresent(DataFormats.Text))
{
textBox1.Text = (string)iData.GetData(DataFormats.Text);
}
粘贴图像
Clipboard.SetDataObject(str);
IDataObject iData=System.Windows.Forms.Clipboard.GetDataObject();
if(iData.GetDataPresent(DataFormats.Text))
{
textBox1.Text = (string)iData.GetData(DataFormats.Text);
}
private void button5_Click(object sender, System.EventArgs e)
{
Clipboard.SetDataObject(pictureBox1.Image);
}
private void button6_Click(object sender, System.EventArgs e)
{
IDataObject iData=System.Windows.Forms.Clipboard.GetDataObject();
pictureBox2.Image=(Bitmap)iData.GetData(DataFormats.Bitmap);
}
{
Clipboard.SetDataObject(pictureBox1.Image);
}
private void button6_Click(object sender, System.EventArgs e)
{
IDataObject iData=System.Windows.Forms.Clipboard.GetDataObject();
pictureBox2.Image=(Bitmap)iData.GetData(DataFormats.Bitmap);
}