I have a multiline textbox where I display app log. If the length is > than 1k characters, I substr the log. The problem is that it’s flickering. I use timer control to update textbox with condition if data differs.
Any way around this? or is there a better way to show log? Thanks!
// this is inside timer
if(txt_log.Text != MY_LOG_VAR){
txt_log.Text = MY_LOG_VAR;
}
// function to update log
public void Log(string data){
MY_LOG_VAR = data + "\r\n" + MY_LOG_VAR;
if(MY_LOG_VAR.Length > 1000){
substr...
}
}
The Log function could be called even 20 times a second, the timer interval is set to 100 seconds;
it doesn’t flicker much, but if a lot of data is submitted to the log it does, I need a solution that would allow the textbox to be even full screen and not flicker.. Thanks!
You should try to use TextBox.AppendText instead of replacing the entire content of your textbox.
This is not the same as putting the new text in front of the previous one, but I think that should stop the flicker.
I have done some test with a RichTextBox and there is no flicker at all
(exactly as Hans Passant said in its answer)…
For example, scrolling without flickering