c#中的'复制','粘贴','撤消','剪切'

 private void 撤消UToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //文本的撤消
            this.richTextBox1.Undo();
        }

        private void 剪切TToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //文本的剪切
            if (richTextBox1.SelectedText.Length > 0)
            {
                try
                {
                    this.richTextBox1.Cut();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

        }

        private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //文本的复制

            // 判断是否选中文本
            if (richTextBox1.SelectedText.Equals(""))
                return;
            Clipboard.SetDataObject(richTextBox1.SelectedText, true);
        }

        private void 粘贴PToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //文本的粘贴
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                this.粘贴PToolStripMenuItem.Enabled = true;
                this.richTextBox1.Paste();
            }
            else
            {
                this.粘贴PToolStripMenuItem.Enabled = false;
            }

        }

        private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

转载于:https://www.cnblogs.com/SharLong/archive/2008/09/26/1299403.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值