c#操作剪贴板

//粘贴
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("已复制到剪贴板!");
    }
}

 

posted @ 2015-07-04 16:00  Yusarin  阅读(159)  评论(0编辑  收藏  举报