重写TextBox的OnPaint方法,为什么不行?
public class MyTextBox : TextBox
{
private Color _BorderColor = Color.Black;
public MyTextBox()
{
base.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
public Color BorderColor
{
get{return _BorderColor;}
set{_BorderColor = value; Invalidate(); }
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawRectangle(new Pen(_BorderColor),0,0,base.Width,base.Height);
MessageBox.Show("ok");
}
}