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
"Joe Keller" <jos...@ameritech.net> wrote in message
news:Snf0b.27102$Vx2.12...@newssvr28.news.prodigy.com...
Joe
"Rick Spiewak" <ricks...@mindspring.com> wrote in message
news:umotTVgZ...@TK2MSFTNGP10.phx.gbl...
However, if I use the same code and instead inherit from "Control" the
OnPaint() event fires correctly.
Any suggestions?
Thanks,
Joe
"Joe Keller" <jos...@ameritech.net> wrote in message
news:7sn0b.27163$Vx2.12...@newssvr28.news.prodigy.com...
--
Tim Wilson
Windows Embedded MVP
"Joe Keller" <jos...@ameritech.net> wrote in message
news:_%n0b.27170$Vx2.12...@newssvr28.news.prodigy.com...
"Tim Wilson [MVP]" <Tim_W...@Rogers.com> wrote in message
news:%231GdBjk...@TK2MSFTNGP12.phx.gbl...
Joe
"Tim Wilson [MVP]" <Tim_W...@Rogers.com> wrote in message
news:%231GdBjk...@TK2MSFTNGP12.phx.gbl...
--
Tim Wilson
Windows Embedded MVP
"Rick Spiewak" <ricks...@mindspring.com> wrote in message
news:%230y4B6k...@TK2MSFTNGP09.phx.gbl...