?
Solved

Scroll to bottom of rich text box without the flicker

Posted on 2006-06-27
9
Medium Priority
?
585 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:jm021196
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 750 total points
ID: 16995336
Hi jm021196;

Before updating the RichTextBox do a .SuspendLayout

    richTextBox1.SuspendLayout();

and after you finished updating the control do a ResumeLayout

    richTextBox1.ResumeLayout();

Fernando
0
 
LVL 1

Author Comment

by:jm021196
ID: 16995789
Hiya,

There is a slight improvement, but really not that noticable, its still doing the jumping lots.

Any more suggestions?

mitch
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 16995882
Can you post the code that updates the richTextBox control?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:jm021196
ID: 16995951
       /// <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.InvokeRequired)
            {
                SetTextCallBack d = new SetTextCallBack(addToStatus);
                this.Invoke(d, new object[] { statusMessage, bold });
            }
            else
            {
                this.rtbStatus.SuspendLayout();
                if (this.rtbStatus.Text.Length > 4096)
                {
                    this.rtbStatus.Text = this.rtbStatus.Text.Substring(this.rtbStatus.Text.IndexOf("\n"));
                }

                statusMessage = getCurrentTimeStamp() + statusMessage + "\n";
                if (bold)
                {
                    statusMessage = "=-=-==-=" + statusMessage;
                }

                this.rtbStatus.AppendText(statusMessage);


                this.rtbStatus.Focus();
                this.rtbStatus.ScrollToCaret();
                this.rtbStatus.ResumeLayout();
            }
        }
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 16996262
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(ControlStyles.DoubleBuffer |
            ControlStyles.UserPaint |
            ControlStyles.AllPaintingInWmPaint,
            true);
      this.UpdateStyles();
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17142808
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
0
 
LVL 1

Author Comment

by:jm021196
ID: 17160945
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
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question