J
Joe Keller
Hello,
I'm attempting to override a text box control to draw a custom border around
the control when the control has the focus using this snippet of code:
public class MyTextBox: System.Windows.Forms.TextBox
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics gr = e.Graphics;
using (Pen penDraw = new Pen(Color.Red))
{
gr.DrawRectangle(penDraw,0,0,this.Width-4,this.Height-4);
}
//base.OnPaint(e);
}
}
If I inherit from Systems.Windows.Forms.Control the rectangle is drawn as
expected. However, if I inherit from the TextBox class (as shown above),
nothing is drawn - why?
I really would not like to build up all of the functionality of a text box
myself from a base "Control" class but would rather take all of the
functionality currently in a TextBox control and just extend it a little.
Any help appreciated!
Thanks,
Joe
I'm attempting to override a text box control to draw a custom border around
the control when the control has the focus using this snippet of code:
public class MyTextBox: System.Windows.Forms.TextBox
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics gr = e.Graphics;
using (Pen penDraw = new Pen(Color.Red))
{
gr.DrawRectangle(penDraw,0,0,this.Width-4,this.Height-4);
}
//base.OnPaint(e);
}
}
If I inherit from Systems.Windows.Forms.Control the rectangle is drawn as
expected. However, if I inherit from the TextBox class (as shown above),
nothing is drawn - why?
I really would not like to build up all of the functionality of a text box
myself from a base "Control" class but would rather take all of the
functionality currently in a TextBox control and just extend it a little.
Any help appreciated!
Thanks,
Joe