C# 复制 粘贴 剪切 撤销
//復制
try
{
this.Cursor = Cursors.WaitCursor;
string strTemp = richTextBoxSendInfo.SelectedText;
//獲取RichTextBox中選中的文字
if (strTemp.Equals("")) //判斷是否為空
return;
Clipboard.Clear();//清除原有剪切板中內容
Clipboard.SetText(strTemp);//將文字添加到剪切板中,還添加Object類型數據
this.Cursor = Cursors.Default;
}
catch (System.Exception ex)
{
this.Cursor = Cursors.Default;
CommonFunc.DisplayException(ex);
}
//粘貼
try
{
this.Cursor = Cursors.WaitCursor;
this.richTextBoxSendInfo.Paste();//粘貼
this.Cursor = Cursors.Default;
}
catch (System.Exception ex)
{
this.Cursor = Cursors.Default;
CommonFunc.DisplayException(ex);
}
//剪切
try
{
this.Cursor = Cursors.WaitCursor;
string strTemp = richTextBoxSendInfo.SelectedText;
if (strTemp.Equals(""))
return;
Clipboard.Clear();
richTextBoxSendInfo.Cut();
this.Cursor = Cursors.Default;
}
catch (System.Exception ex)
{
this.Cursor = Cursors.Default;
CommonFunc.DisplayException(ex);
}
//撤銷
try
{
this.Cursor = Cursors.WaitCursor;
richTextBoxSendInfo.Undo();
this.Cursor = Cursors.Default;
}
catch (System.Exception ex)
{
this.Cursor = Cursors.Default;
CommonFunc.DisplayException(ex);
}
?
總結
以上是生活随笔為你收集整理的C# 复制 粘贴 剪切 撤销的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ExtJs学习准备工作(二) fireb
- 下一篇: Exchange Server2010系