public void InvalidateRange(int a, int b) { if (a < 0) { a = 0; } if (b < 0) { b = 0; } if (a > b) { int t = b; b = a; a = t; } int lineTop = tv.DisplayLineFromPosition(a); int lineDocBottom = panel.pdoc.pbuffer.LineFromPosition(b) + 1; int lineBottom = tv.fs.DisplayFromDoc(lineDocBottom); SRectangle rcInvalidate = new SRectangle(); rcInvalidate.left = 0; rcInvalidate.right = 2000; rcInvalidate.top = (lineTop - panel.ScrollPos()) * tv.lineHeight; rcInvalidate.bottom = (lineBottom - panel.ScrollPos()) * tv.lineHeight; // Allow for decorators that go 2 pixels beyond line. rcInvalidate.top -= 2; rcInvalidate.bottom += 2; Invalidate(new Rectangle(rcInvalidate.left, rcInvalidate.top, rcInvalidate.Width(), rcInvalidate.Height())); }