OnPaint override
I have a class that inherits from the RichTextBox control. I need to do some custom drawing on the RichTextBox, so I override the paint event and do the custom drawing:
protected override void OnPaint(PaintEventArgs e)
{
// draw normally
base.OnPaint (e);
// add our custom border
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Black, ButtonBorderStyle.Solid);
}
Simple enough, right? Well, when I run the app, every time I enter text into the control, the custom drawing I did gets cleared. Why is that? Is there a way around this?

katanaRank #7,224 · 246 reputationPosted Oct 7, 2003, 1:13 PM EDT
chrishornbergerRank #2,700 · 517 reputationPosted Oct 7, 2003, 2:09 PM EDT
katanaRank #7,224 · 246 reputationPosted Oct 7, 2003, 3:14 PM EDT
chrishornbergerRank #2,700 · 517 reputationPosted Oct 7, 2003, 3:51 PM EDT
Mahesh ChandRank #1 · 393.3K reputationPosted Oct 8, 2003, 5:21 AM EDT
ssswamiiRank #4,500 · 340 reputationPosted Oct 8, 2003, 7:23 AM EDT
andrewRank #6,347 · 269 reputationPosted Oct 8, 2003, 7:51 AM EDT
katanaRank #7,224 · 246 reputationPosted Oct 8, 2003, 8:08 AM EDT