C#WinForm中复制、粘贴文本到剪贴板

//复制:
private void button1_Click(object sender, System.EventArgs e) {
 
  if(textBox1.SelectedText != "")
     Clipboard.SetDataObject(textBox1.SelectedText);
}
 
//粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  IDataObject iData = Clipboard.GetDataObject();
  if(iData.GetDataPresent(DataFormats.Text)) {
     textBox2.Text = (String)iData.GetData(DataFormats.Text);
  }
}

posted on 2014-09-25 10:08  罗曼飞羽  阅读(515)  评论(0编辑  收藏  举报

导航