111,119
社区成员
发帖
与我相关
我的任务
分享
public class MyTextBox : TextBox
{
public MyTextBox()
{
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer, true);
this.UpdateStyles();
}
protected override void OnPaint(PaintEventArgs pevent)
{
TextRenderer.DrawText(pevent.Graphics, this.Text, this.Font, new Point(2, 2), this.ForeColor);
}
}
if (!this.Enabled)
{
TextBoxRenderer.DrawTextBox(e.Graphics, this.Bounds, System.Windows.Forms.VisualStyles.TextBoxState.Readonly);
TextRenderer.DrawText(e.Graphics, this.Text, this.Font, new Point(-1, 1), this.ForeColor);
}
else
base.OnPaint(e);
class MyTextBox:TextBox
{
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer, !this.Enabled);
this.UpdateStyles();
}
protected override void OnPaint(PaintEventArgs e)
{
if (!this.Enabled)
TextRenderer.DrawText(e.Graphics, this.Text, this.Font,new Point(-1,1), this.ForeColor);
else
base.OnPaint(e);
}
}