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 9196575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:52:48+00:00 2026-06-17T21:52:48+00:00

I have Form1, RichTextBox1 and Button1 on my Form To understand what i’m trying

  • 0

I have Form1, RichTextBox1 and Button1 on my Form

To understand what i’m trying to do; take a look at this link, type in a facebook profile link and click on Hack Account AND SEE THE GREEN TEXT THAT APPEARS

I’m using the code below in C# to achieve what i want to do :

private void button1_Click(object sender, EventArgs e)
    {
        string myStr = "This is a test string to stylize your RichTextBox1";

        foreach (char c in myStr.ToCharArray()) {

            Thread.Sleep(100);
            richTextBox1.AppendText(c.ToString());

        }
    }

But it doesn’t work, the text appears in the text box at one time; Not char by char!

  • 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-06-17T21:52:50+00:00Added an answer on June 17, 2026 at 9:52 pm

    The reason your code is showing all the text at once is using Thread.Sleep() keep the main Thread (the UI thread) suspended / sleep mode, so none of the Application message are processed on form & the form paint / drawing event are not doing the job as the UI thread is sleeping/suspended!


    Solution 1: Use a helper Thread so that Thread.Sleep() dont make ur app go in non-responsive mode

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            string myStr = "This is a test string to stylize your RichTextBox1";
    
            ThreadPool.QueueUserWorkItem(ShowTextInInterval, myStr);
        }
    
        private void ShowTextInInterval(object state)
        {
            string mystr = state as string;
            if (mystr == null)
            {
                return;
            }
            for (int i = 0; i < mystr.Length; i++)
            {
                AppendNewTextToRichTextBox(mystr[i]);
                Thread.Sleep(100);
            }
        }
    
        private delegate void app_char(char c);
        private void AppendNewTextToRichTextBox(char c)
        {
            if (InvokeRequired)
            {
                Invoke(new app_char(AppendNewTextToRichTextBox), c);
            }
            else
            {
                richTextBox1.AppendText(c.ToString(CultureInfo.InvariantCulture));
            }
        }
    
    
    
    }
    

    Solution # 2 : Use a timer

    public partial class Form1 : Form
    {
        private Timer tbTimer = new Timer();
        string myStr = "This is a test string to stylize your RichTextBox1";
        private int charPos = 0;
        public Form1()
        {
            InitializeComponent();
            tbTimer.Interval = 100;
            tbTimer.Tick += TbTimerOnTick;
    
        }
    
        private void TbTimerOnTick(object sender, EventArgs eventArgs)
        {
            if (charPos < myStr.Length - 1)
            {
                richTextBox1.AppendText(myStr[charPos++].ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                tbTimer.Enabled = false;
            }
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            tbTimer.Enabled = true;
        }
    
    
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form1.cs and in that form I have a panel1, in the
I have a form (Form1) that has a NotifyIcon on it. I have another
I have a windows form (Form1) which when a button is clicked on it
I have a winform application (one form), on this form there is a RichTextBox.
I have a C# .NET 3.5 Windows Form program with this method: private void
I have a form which has a RichTextBox docked to the left and DataGridView
I have a Windows Form with a RichTextBox on it. The content of the
In Form1 I have PageControl. At run time my program creates tab sheets. In
I have 2 forms : Form1 , Form2 . Form1 has checkedlistbox : checkedlistbox1
I have three forms: Form1 (Which is Mdi) Form2 (child of mdi) Form3 (child

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.