I have a label that shows line numbers based on RichTextBox text. I bound the Vscroll event to handle marking.
private void rtbLogicCode_VScroll(object sender, EventArgs e) { Point pt = new Point(0, 1); int firstIndex = rtbLogicCode.GetCharIndexFromPosition(pt); int firstLine = rtbLogicCode.GetLineFromCharIndex(firstIndex); pt.X = ClientRectangle.Width; pt.Y = ClientRectangle.Height; int lastIndex = rtbLogicCode.GetCharIndexFromPosition(pt); int lastLine = rtbLogicCode.GetLineFromCharIndex(lastIndex);
Everything seems to work correctly, except that RichTextBox uses the Smooth Scrolling function, which in many cases spins my line numbering when the user did not scroll all the way to the next line. This results in line numbers not being synchronized with the actual text displayed in the RichTextBox.
In the end, I need to disable the smoothscrolling function in order to accomplish this. I was told that you can redefine the PostMessage RichTextBox API to disable the specified function, but after searching through many documents I could not find any good ones.
I would appreciate the most detailed decision on how to disable the smooth scrolling feature. Thanks.
source share