Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:29:56+00:00 2026-05-23T13:29:56+00:00

I need to append text to RichTextBox, and need to perform it without making

  • 0

I need to append text to RichTextBox, and need to perform it without making text box scroll or lose current text selection, is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:29:56+00:00Added an answer on May 23, 2026 at 1:29 pm

    The RichTextBox in WinForms is quite flicker happy when you play around with the text and select-text methods.

    I have a standard replacement to turn off the painting and scrolling with the following code:

    class RichTextBoxEx: RichTextBox
    {
      [DllImport("user32.dll")]
      static extern IntPtr SendMessage(IntPtr hWnd, Int32 wMsg, Int32 wParam, ref Point lParam);
    
      [DllImport("user32.dll")]
      static extern IntPtr SendMessage(IntPtr hWnd, Int32 wMsg, Int32 wParam, IntPtr lParam);
    
      const int WM_USER = 0x400;
      const int WM_SETREDRAW = 0x000B;
      const int EM_GETEVENTMASK = WM_USER + 59;
      const int EM_SETEVENTMASK = WM_USER + 69;
      const int EM_GETSCROLLPOS = WM_USER + 221;
      const int EM_SETSCROLLPOS = WM_USER + 222;
    
      Point _ScrollPoint;
      bool _Painting = true;
      IntPtr _EventMask;
      int _SuspendIndex = 0;
      int _SuspendLength = 0;
    
      public void SuspendPainting()
      {
        if (_Painting)
        {
          _SuspendIndex = this.SelectionStart;
          _SuspendLength = this.SelectionLength;
          SendMessage(this.Handle, EM_GETSCROLLPOS, 0, ref _ScrollPoint);
          SendMessage(this.Handle, WM_SETREDRAW, 0, IntPtr.Zero);
          _EventMask = SendMessage(this.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero);
          _Painting = false;
        }
      }
    
      public void ResumePainting()
      {
        if (!_Painting)
        {
          this.Select(_SuspendIndex, _SuspendLength);
          SendMessage(this.Handle, EM_SETSCROLLPOS, 0, ref _ScrollPoint);
          SendMessage(this.Handle, EM_SETEVENTMASK, 0, _EventMask);
          SendMessage(this.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
          _Painting = true;
          this.Invalidate();
        }
      }
    }
    

    and then from my form, I can happily have a flicker-free richtextbox control:

    richTextBoxEx1.SuspendPainting();
    richTextBoxEx1.AppendText("Hey!");
    richTextBoxEx1.ResumePainting();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ask user to input a URL in a text-box and need to append
I need to append text repeatedly to an existing file in Java. How do
I need to append some text to an input field...
HTML is <a>ref</a> I need to get <a>ref</a>text How can i do this? $('a').append('text')
I need to edit file , the main issue is to append text between
Good day. I found the example below, I need to append some more text
I need to append text to win32 edit control i have working function to
I need to create/append a text file and write some data in that. When
I have a folder full of text files. I need to append the same
I'm trying to impliment a confirmation box, but I need to edit the text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.