我用readonly则他不能编辑,但是光标还在,还可以选择变成蓝色。
Enable为false时,背景色就变成系统默认色了
有没有方法让他不能操作?
让她不能编辑又没有光标!或者得到光标后立刻光标消失?

解决方案 »

  1.   

    Enable是可不可用你都让他不可用了。。那还怎么操作啊
      

  2.   

    自己做一个派生类,然后自己画吧
    public class MyRichTextBox : RichTextBox
        {
            protected override void OnEnabledChanged(EventArgs e)
            {
                base.OnEnabledChanged(e);
                if (this.Enabled)
                    this.SetStyle(ControlStyles.UserPaint, false);
                else
                    this.SetStyle(ControlStyles.UserPaint, true);
                //再描绘
                this.Invalidate();        }
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
                System.Drawing.Brush b =
                    new System.Drawing.SolidBrush(this.BackColor);
                //描绘字符串
                //e.Graphics.DrawString(this.Text, this.Font, b, -1, 1);
                Rectangle t = new Rectangle(this.Location.X, this.Location.Y, this.Width, this.Height);
                e.Graphics.FillRectangle(b, this.Location.X, this.Location.Y, this.Width, this.Height);
                System.Drawing.Brush fb =
                    new System.Drawing.SolidBrush(this.ForeColor);
                //e.Graphics.DrawString(
                e.Graphics.DrawString(this.Text, this.Font, fb, t);
                
                b.Dispose();        }
        }