想做个在richTextBox中以蓝色选中区按下鼠标右键提示复制,并点下复制进行复制.
谢谢

解决方案 »

  1.   

    用contextMenuStrip控件..写个‘复制’后双击产生事件..再在后台写复制代码,最后在到richTextBox
    属性中的contextMenuStrip选择你用的这个contextMenuStrip控件就OK了
      

  2.   

    Form1.Designer.cs
    namespace WindowsApplication15
    {
        partial class Form1
        {
            /// <summary>
            /// 必需的设计器变量。
            /// </summary>
            private System.ComponentModel.IContainer components = null;        /// <summary>
            /// 清理所有正在使用的资源。
            /// </summary>
            /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }        #region Windows 窗体设计器生成的代码        /// <summary>
            /// 设计器支持所需的方法 - 不要
            /// 使用代码编辑器修改此方法的内容。
            /// </summary>
            private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                this.richTextBox1 = new System.Windows.Forms.RichTextBox();
                this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
                this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.contextMenuStrip1.SuspendLayout();
                this.SuspendLayout();
                // 
                // richTextBox1
                // 
                this.richTextBox1.ContextMenuStrip = this.contextMenuStrip1;
                this.richTextBox1.Location = new System.Drawing.Point(12, 12);
                this.richTextBox1.Name = "richTextBox1";
                this.richTextBox1.Size = new System.Drawing.Size(280, 254);
                this.richTextBox1.TabIndex = 0;
                this.richTextBox1.Text = "这里是内容,请选中再右键点复制";
                // 
                // contextMenuStrip1
                // 
                this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.ToolStripMenuItem});
                this.contextMenuStrip1.Name = "contextMenuStrip1";
                this.contextMenuStrip1.Size = new System.Drawing.Size(95, 26);
                // 
                // ToolStripMenuItem
                // 
                this.ToolStripMenuItem.Name = "ToolStripMenuItem";
                this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
                this.ToolStripMenuItem.Text = "复制";
                this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(292, 266);
                this.Controls.Add(this.richTextBox1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.contextMenuStrip1.ResumeLayout(false);
                this.ResumeLayout(false);        }        #endregion        private System.Windows.Forms.RichTextBox richTextBox1;
            private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
            private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
        }
    }Form1.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication15
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Copy(); //将选择文本复制到剪切板
            }
        }
    }