Fastest way to load an array of strings

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by shark92651
Avatar
I have an array of strings that I want to load into the SyntaxEditor. The code below works but it is a bit slow and I can watch the scrollbar change size as it loads the lines. What is the fastest way to load an array of strings and how can I suspend all screen updates until the entire array is loaded? In my particular project I have to read from the array and cannot simply convert the array to a single string as I am inserting additional lines into the text as I process the array.

I tried using SuspendPainting()/ResumePainting() but I still can see the scroll bar change size as it loads.

edFileA.SuspendPainting();

for (int i = 0; i < fileA.Length; i++)
{
edFileA.Document.AppendText(fileA[i]);
}

edFileA.ResumePainting();

Comments (1)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
v4.0 has the ability to suspend lexical parsing which will help however by far the best way to do this is to create a System.Text.StringBuilder and append each line to that. Then do this:
editor.Document.Text = stringBuilder.ToString();
That will only update SyntaxEditor once and will be the fastest.


Actipro Software Support

The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.