C#操作剪贴板实现复制粘贴

时间:2022-09-15 23:33:35

 

 
//粘贴
private void tsbPaste_Click(object sender, EventArgs e)
{
    IDataObject iData = Clipboard.GetDataObject();
    if (iData.GetDataPresent(DataFormats.Text))
    {
        txtContent.Text = (String)iData.GetData(DataFormats.Text);
    }
 
}
 
//复制
private void tsbCopy_Click(object sender, EventArgs e)
{
    if (txtContent.Text != "")
    {
        Clipboard.SetDataObject(txtContent.Text);
        MessageBox.Show("已复制到剪贴板!");
    }
}

 监视剪贴板 

http://www.cnblogs.com/jht/archive/2006/03/20/354088.htm