C# 复制与粘贴
2008-12-15 14:48
211 查看
复制:
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完成。
TextBox复制
txtpass.SelectAll();
txtpass.Copy();
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完成。
TextBox复制
txtpass.SelectAll();
txtpass.Copy();
相关文章推荐
- C# 激活 非活动窗口 并自动 复制 粘贴 回车
- C# 激活 非活动窗口 并自动 复制 粘贴 回车
- C#剪切,复制,粘贴底层应用编写
- C#复制、粘贴文本信息到剪贴板
- C#操作剪贴板实现复制粘贴
- C#.NET 剪切板复制粘贴泛型的例子代码参考 Clipboard Copy Paste List
- C#复制、粘贴文本信息到剪贴板
- C#.NET 剪切板复制粘贴泛型的例子代码参考 Clipboard Copy Paste List
- C#的richtextbox关联右键,右键点击出现复制,粘贴,剪切就可以
- C#剪切,复制,粘贴底层应用编写
- C#禁止textbox复制、粘贴、剪切及鼠标右键的方法
- C# 打开文本文件,剪切文本,复制文本,粘贴文本方法
- 记事本(c#实现,包含,打开,保存,另存为,复制,粘贴等功能)
- C# 激活 非活动窗口 并自动 复制 粘贴 回车
- 剪贴板——C# 复制、粘贴、撤销、剪切功能实现。
- C#中屏蔽复制粘贴
- C#中屏蔽复制粘贴
- C#、devExpress 的 给bandedGrid加菜单功能 :复制、粘贴的例子
- C#复制、粘贴文本信息到剪贴板
- C# WinForm实现粘贴图片到PictureBox及复制PictureBox中的图片