本文主要是介绍剪贴板——C# 复制、粘贴、撤销、剪切功能实现。_控控控-上ke控_新浪博客,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
剪贴板——C# 复制、粘贴、撤销、剪切功能实现
1. 粘贴功能
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
this.textBox1.Paste();
string fzStr = textBox1.Text;
this.Cursor = Cursors.Default;
}
catch (Exception)
{
this.Cursor = Cursors.Default;
}
}
2.复制功能
private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
string fzStr = textBox1.Text;
if (fzStr.Equals(""))
{
return;
}
Clipboard.Clear();
Clipboard.SetText(fzStr);
this.Cursor = Cursors.Default;
}
catch (Exception)
{
this.Cursor = Cursors.Default;
}
}
3. 剪切功能
private void 剪切 CToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
string fzStr = textBox1.Text;
if (fzStr.Equals(""))
{
return;
}
Clipboard.Clear();
this.textBox1.Cut();
this.Cursor = Cursors.Default;
}
catch (Exception)
{
this.Cursor = Cursors.Default;
}
}
4.撤销功能
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
this.textBox1.Undo();
this.Cursor = Cursors.Default;
}
catch (Exception)
{
this.Cursor = Cursors.Default;
}
}
这篇关于剪贴板——C# 复制、粘贴、撤销、剪切功能实现。_控控控-上ke控_新浪博客的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!