HelpNeeder
HelpNeeder

Reputation: 6480

How to disable flickering of scroll bar when constantly changing multiline text box content?

So I'm using this code which moves the cursor to the end of the text box content each time I'm adding something to it.

void txtDisplay_TextChanged(object sender, EventArgs e)
{
    txtDisplay.SelectionStart = txtDisplay.Text.Length;
    txtDisplay.ScrollToCaret();
    txtDisplay.Refresh();
}

The problem is that I see like flickering of text box scroll bar which goes up and down each time I add something to the text box. Doing this 10 times a second seems like it consumes some processing power and it looks ugly.

How to keep the scroll bar scrolled down all the time?

Upvotes: 1

Views: 1128

Answers (1)

Kotch
Kotch

Reputation: 334

Hi there ( again :) ),

I've just looked for some methods to avoid this flickering and I found this post exploring both SelectedText property and AppendText() method, with the lattest actually appending the text and scrolling only if it's necessary.

Hope that'll help !

Upvotes: 1

Related Questions