Drawing over RichTextBox
This worked ok for me:
class RichBox : RichTextBox {
private const int WM_PAINT = 15;
protected override void WndProc(ref Message m) {
if (m.Msg == WM_PAINT) {
this.Invalidate();
base.WndProc(ref m);
using (Graphics g = Graphics.FromHwnd(this.Handle)) {
g.DrawLine(Pens.Red, Point.Empty,
new Point(this.ClientSize.Width - 1,
this.ClientSize.Height - 1));
}
} else {
base.WndProc(ref m);
}
}
}
The events in rich textbox are a pain in the back since they don't fire the way you think they should fire. Here's a post where someone posted the minimum required code to have a new control that exposes the proper paint events for you by hosting a rich textbox and intercepting the windows paint requests. It is in VB.Net but should be easy to translate it for your use.