richtextbox背景色问题 我用readonly则他不能编辑,但是光标还在,还可以选择变成蓝色。Enable为false时,背景色就变成系统默认色了有没有方法让他不能操作?让她不能编辑又没有光标!或者得到光标后立刻光标消失? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Enable是可不可用你都让他不可用了。。那还怎么操作啊 自己做一个派生类,然后自己画吧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(); } } 1970.1.1 如何使用C#代码删除excel中指定工作表的前三行数据 哪位高手有用过C#2005的reportViewer报表控件呢? 如何在dataset中查询表中一条记录 Process.Start 能启动一个问装成其他扩展名的exe文件么? 品牌高手请现身吧,我含泪送分.net2005web设计模式+owc11图表问题 数据库连接 如何得到axWebBrowser的cookie!!! 问一个简单的问题:get和set方法怎么会保护类呢? 在C#中如何备份Access数据库? winfrom 控件,设置Location位置,设置不对,是怎么回事? 什么叫 .net Mvc 开发?
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(); }
}