Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert data in RichTextBox C#

Tags:

c#

My code:

private void timer4_Tick(object sender, EventArgs e)
{
    for (int a = 0; a < 10; a++)
    {
        var infos = webBrowser1.Document.GetElementsByTagName("img")[a].GetAttribute("src");
        richTextBox1.Text = infos;
    }
    timer4.Stop();
}

I want to insert all of 10 src values in RichTextBox, while my code do it only once.

like image 350
marko121 Avatar asked Apr 15 '26 15:04

marko121


2 Answers

You can use AppendText

Replace

richTextBox1.Text = infos;

with

richTextBox1.AppendText(infos);

OR

richTextBox1.Text += infos + Environment.NewLine;
like image 81
NASSER Avatar answered Apr 18 '26 06:04

NASSER


This line is wrong.

richTextBox1.Text = infos; 

This is right.

richTextBox1.AppendText= infos;
like image 42
zhangyiying Avatar answered Apr 18 '26 05:04

zhangyiying



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!