[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Scroll to bottom of rich text box without the flicker

Posted on 2006-06-27
9
Medium Priority
?
590 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 64

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 64

Expert Comment

by:Fernando Soto
ID: 16995882
Can you post the code that updates the richTextBox control?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 64

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 64

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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