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 @ 2013-05-08 17:23  lhfly  阅读(16259)  评论(3编辑  收藏  举报