Hi guys,

I'm writing a simple text editor with syntax highlighting feature, my code depend on a timer object to update the whole text every 1 sec., I found it's difficult to select all the text due to the regular updating of the text after timer ticks.

So, Is there any way around this.

Thanks

[EL-Prince]

You can store the current selection and reapply it after you have processed the text:

private void timer2_Tick(object sender, EventArgs e)
        {
            int start = txtHighlight.SelectionStart;
            int length = txtHighlight.SelectionLength;

            //process text

            txtHighlight.Select(start, length);
        }

Thanks a lot for your share, but this's what I did!!!

Be a part of the DaniWeb community

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