[转]C# 内容复制到剪贴板
2010-03-10 11:31
204 查看
复制:
private void button1_Click(object sender, System.EventArgs e) {
// Takes the selected text from a text box and puts it on the clipboard.
if(textBox1.SelectedText != ”")
Clipboard.SetDataObject(textBox1.SelectedText);
}
粘贴:
private void button2_Click(object sender, System.EventArgs e) {
// Declares an IDataObject to hold the data returned from the clipboard.
// Retrieves the data from the clipboard.
IDataObject iData = Clipboard.GetDataObject();
// Determines whether the data is in a format you can use.
if(iData.GetDataPresent(DataFormats.Text)) {
// Yes it is, so display it in a text box.
textBox2.Text = (String)iData.GetData(DataFormats.Text);
}
}
主要通过调用Clipborad的API完成。
private void button1_Click(object sender, System.EventArgs e) {
// Takes the selected text from a text box and puts it on the clipboard.
if(textBox1.SelectedText != ”")
Clipboard.SetDataObject(textBox1.SelectedText);
}
粘贴:
private void button2_Click(object sender, System.EventArgs e) {
// Declares an IDataObject to hold the data returned from the clipboard.
// Retrieves the data from the clipboard.
IDataObject iData = Clipboard.GetDataObject();
// Determines whether the data is in a format you can use.
if(iData.GetDataPresent(DataFormats.Text)) {
// Yes it is, so display it in a text box.
textBox2.Text = (String)iData.GetData(DataFormats.Text);
}
}
主要通过调用Clipborad的API完成。
相关文章推荐
- C#.net中,点击asp控件button复制内容到剪贴板
- C# 把TextBox中选中的内容复制到剪贴板
- C# Winform ListView实现单元格双击复制内容到剪贴板
- 通过JS+H5实现复制内容到剪贴板上
- 黄聪:C#实现WORD文档的内容复制和替换
- JavaScript复制内容到剪贴板
- js复制内容到剪贴板
- C# 复制、粘贴文本信息到剪贴板
- C#:当把U盘放插入,然后程序自动将U盘的内容复制到本地硬盘
- C# 将 DataTable t1 内容复制到 DataTable t2中
- C#复制、粘贴文本到剪贴板
- C#操作剪贴板实现复制粘贴
- C# js jquery复制textbox内容总结
- Android 复制文本内容到系统剪贴板的最简单实例(分享)
- 【转】C#复制、粘贴文本信息到剪贴板
- C#复制、粘贴文本到剪贴板
- C# 复制数据至剪贴板
- c# 复制文件夹及文件夹下所有的内容
- JavaScript之Clipboard.js实现复制内容到剪贴板
- 使用clipboard.js实现复制文本内容到剪贴板