jm021196
asked on
Scroll to bottom of rich text box without the flicker
I'm trying to create a 'text buffer' that holds about 300 lines of text.
When the buffer fills up it should chop a few lines off the top and stay scrolled to the bottom.
However everything i try creates a 'flicker' where the text box scrolls to the top, does what it has to do and scrolls to the bottom. I'm looking for this to be non jumping
(if you have ever used the program mIRC then it should act like the status window there, text appears at the bottom, scroll stays at the bottom, and the text that has overrun the max number of lines gets chopped off the top)
Any help would be apprechiated.
mitch
When the buffer fills up it should chop a few lines off the top and stay scrolled to the bottom.
However everything i try creates a 'flicker' where the text box scrolls to the top, does what it has to do and scrolls to the bottom. I'm looking for this to be non jumping
(if you have ever used the program mIRC then it should act like the status window there, text appears at the bottom, scroll stays at the bottom, and the text that has overrun the max number of lines gets chopped off the top)
Any help would be apprechiated.
mitch
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you post the code that updates the richTextBox control?
ASKER
/// <summary>
/// Add to the status RTB (Thread safe)
/// </summary>
/// <param name="statusMessage">Text to display</param>
/// <param name="bold">bold</param>
public void addToStatus(string statusMessage, bool bold)
{
if (this.rtbStatus.InvokeRequ ired)
{
SetTextCallBack d = new SetTextCallBack(addToStatu s);
this.Invoke(d, new object[] { statusMessage, bold });
}
else
{
this.rtbStatus.SuspendLayo ut();
if (this.rtbStatus.Text.Lengt h > 4096)
{
this.rtbStatus.Text = this.rtbStatus.Text.Substr ing(this.r tbStatus.T ext.IndexO f("\n"));
}
statusMessage = getCurrentTimeStamp() + statusMessage + "\n";
if (bold)
{
statusMessage = "=-=-==-=" + statusMessage;
}
this.rtbStatus.AppendText( statusMess age);
this.rtbStatus.Focus();
this.rtbStatus.ScrollToCar et();
this.rtbStatus.ResumeLayou t();
}
}
/// Add to the status RTB (Thread safe)
/// </summary>
/// <param name="statusMessage">Text to display</param>
/// <param name="bold">bold</param>
public void addToStatus(string statusMessage, bool bold)
{
if (this.rtbStatus.InvokeRequ
{
SetTextCallBack d = new SetTextCallBack(addToStatu
this.Invoke(d, new object[] { statusMessage, bold });
}
else
{
this.rtbStatus.SuspendLayo
if (this.rtbStatus.Text.Lengt
{
this.rtbStatus.Text = this.rtbStatus.Text.Substr
}
statusMessage = getCurrentTimeStamp() + statusMessage + "\n";
if (bold)
{
statusMessage = "=-=-==-=" + statusMessage;
}
this.rtbStatus.AppendText(
this.rtbStatus.Focus();
this.rtbStatus.ScrollToCar
this.rtbStatus.ResumeLayou
}
}
Hi jm021196;
Place the following code in the Form Load event. It will enable double buffering. This will do updates of the screen in off screen memory and when done will paint the screen all at once. This should eliminate screen flickering.
// Setup the form for double buffering to fix screen flicker
this.SetStyle(ControlStyle s.DoubleBu ffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingI nWmPaint,
true);
this.UpdateStyles();
Place the following code in the Form Load event. It will enable double buffering. This will do updates of the screen in off screen memory and when done will paint the screen all at once. This should eliminate screen flickering.
// Setup the form for double buffering to fix screen flicker
this.SetStyle(ControlStyle
ControlStyles.UserPaint |
ControlStyles.AllPaintingI
true);
this.UpdateStyles();
Hi Bob;
I would like to see a resolution to this question seeming I gave m021196 a solution that should have corrected the problem.
Thanks;
Fernando
I would like to see a resolution to this question seeming I gave m021196 a solution that should have corrected the problem.
Thanks;
Fernando
ASKER
Hiya,
Sorry about the late responses, I was called away on business at the last moment.
Unfortunetly FernandoSoto's answer didn't work but because he was the only person who answered and I'm not going to be around for a bit I'll award him the points.
Thanks
mitch
Sorry about the late responses, I was called away on business at the last moment.
Unfortunetly FernandoSoto's answer didn't work but because he was the only person who answered and I'm not going to be around for a bit I'll award him the points.
Thanks
mitch
ASKER
There is a slight improvement, but really not that noticable, its still doing the jumping lots.
Any more suggestions?
mitch