|
-
Apr 18th, 2008, 07:16 PM
#1
Thread Starter
Hyperactive Member
[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.
Last edited by Dmitri K; Apr 24th, 2008 at 02:53 PM.
-
Apr 18th, 2008, 10:52 PM
#2
Re: RichTextBox color problem
i think you would need to change the text of the richtextbox, not the textrtf
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 21st, 2008, 04:16 PM
#3
Thread Starter
Hyperactive Member
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.
-
Apr 24th, 2008, 02:49 PM
#4
Thread Starter
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|