disable scrolling when selecting text in richTextBox (C#)
I have a rich text box that contains (a lot of) text. I've added a search option for it, and when the user presses the search button, the program marks all the matches in yellow (by performing selectionBackColor on each selection) and then selects the first match. The result is that the program looks like it "scans" the text and then selects the first match. I don't want this to happen so I need to disable the autoscrolling (that occurs when performing Select()) for a specific code segment. I searched this problem before posting and the main topics I found involved appending text, and that'开发者_StackOverflows not my case. Any idea of how to solve my problem?
I'm using .NET framework 4 (visual studio 2010) and I write in C#.
Thanks in advance, Guy
Well it seems that I'll answer my own question - all I had to do was to put these two lines among with the other class's properties:
[DllImport("user32.dll", EntryPoint = "LockWindowUpdate", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr LockWindow(IntPtr Handle);
and surround the desired code segment with this at the start:
LockWindow(this.Handle);
and this at the end:
LockWindow(IntPtr.Zero);
精彩评论