Can I stop updating the user display of a control (rich text box) temporarily? I want it to process what I tell but not change how it looks for just a small piece of code.
Please help :)

Recommended Answers

All 5 Replies

Put BeginUpdate() and EndUpdate() around the code. If your control is called rtbText then

' your update code goes here

My rich text box has not BeginUpdate() or EndUpdate() methods. I use 2005. Has the rich text box changed? Can you upload the new one if yes?

My apologies. I assumed that the Begin/EndUpdate methods applied to the rich text control as well. I would have thought these were methods that would be useful if they applied to all controls. If they don't in my version (2010) then they won't in yours. What, specifically, are you trying to do? Perhaps with more information I can suggest an alternative.

I am making a kind of program in which you can enter the text in the rich text box by buttons like a virtual keyboard. Then I use find() method and change some text to just one letter. I use this code. For example if I want to change "you" to "u" then I have:

rtfDocument.SelectionStart = rtfDocument.Find("You")

        rtfDocument.SelectionLength = Len("You")

        If rtfDocument.SelectedText = "You" Then
            rtfDocument.SelectedText = "u"
        End If

But when the text gets big, it starts to blink when it processes lots of such codes each time I press a button from the virtual keyboard.
Hope you have understood.
Thanks in advance :)

I was thinking that you could copy the entire RTF text to a local string, do all of the changes to that string, then copy it back to the RTF control but it occurred to me that you would lose all of the formatting. Then I thought you might create a hidden RTF control and do all the editing changes there before copying it back to the visible control. That might eliminate all but one (the final) screen update.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.