[RESOLVED] RichTextBox color problem
Hey guys,
i have a large amount of text in my richtextbox (RTB) so I have to use scroll bars. The problem is if I try to highlight any instance of a certain word thruout the whole text, the scroll bars jump around and even tho I return to the original insertion position, the scroll bars could still be offset from original.
Is there a way to force RTB to not scroll when something out of "visible range" is selected (for example, using txtRTB.Find "mystring" to highlight)?
Since I couldn't find a solution, I tried to edit the colors directly in the .TextRTF instead, however the following code has no affect and doesn't update the RTB, .TextRTF stays the same
P.S. .TextRTF has instances of "mystring", I double-checked and RTB's color table is fine also:
{\colortbl ;\red0\green128\blue0;\red255\green0\blue0;}
Code:
RTFStr = .TextRTF
RTFStr = Replace(RTFStr, "mystring", "\cf1 mystring\cf0 ")
.TextRTF = RTFStr
.TextRTF stays the same, all "mystring" are still "mystring", not the wanted "\cf1 mystring\cf0 ", however if i replace "mystring" with "newstring", it does change fine, so it has something to do with changing "\cf#" flags, in this case \cf1 and \cf0; anyone knows how to force the RTB to accept actual RTF code changes?
Thanks.
Re: RichTextBox color problem
i think you would need to change the text of the richtextbox, not the textrtf
Re: RichTextBox color problem
Hey,
thanks for the reply. Unfortunately changing the .Text instead of .TextRTF will actually show all the rtf code in the text, so that doesn't work.
Any other ideas?
Thanks.
Re: RichTextBox color problem
In case anyone interested in the future.
I solved this problem by using GetScrollInfo/SetScrollInfo which combined with .SelStart/.SelLength will return the window to the original location including the insertion point. There are still minor problems with right border offset, but it's better than nothing.