overrride onpaint
-
why it doesn't work? It show the draw i want, but when i write text the draw disappear: public partial class UserControl1 : TextBox { public UserControl1() { this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); this.BorderStyle = BorderStyle.None; InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Pen p = new Pen(Color.Red ,3.0f); g.DrawRectangle(p, new Rectangle(0, 0, this.Width, this.Height)); } }
-
why it doesn't work? It show the draw i want, but when i write text the draw disappear: public partial class UserControl1 : TextBox { public UserControl1() { this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); this.BorderStyle = BorderStyle.None; InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Pen p = new Pen(Color.Red ,3.0f); g.DrawRectangle(p, new Rectangle(0, 0, this.Width, this.Height)); } }
Sasuko wrote:
but when i write text the draw disappear:
Do you mean that the text you type is never displayed? If so, I would expect this is happening because your
OnPaint()
method isn't writing it. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com -
why it doesn't work? It show the draw i want, but when i write text the draw disappear: public partial class UserControl1 : TextBox { public UserControl1() { this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); this.BorderStyle = BorderStyle.None; InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Pen p = new Pen(Color.Red ,3.0f); g.DrawRectangle(p, new Rectangle(0, 0, this.Width, this.Height)); } }
OnPaint doesnt fire for TextBox based controls. Its by design. You will have to hack with P/Invoke.**
xacc.ide-0.1.3.12 - Now a whole lot faster (and better)
Consolas size screenshots (see how fractional font sizes look)**