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();
        }

posted @ 2008-09-26 11:14  ︾:ˇ﹁臉憂傷  阅读(969)  评论(1)    收藏  举报