Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i add all the strings from a List<string> to a textbox?
    text
    copied!<pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (true) { if ((worker.CancellationPending == true)) { e.Cancel = true; break; } else { string content = downloadContent(); GetProfileNames(content); GetTextFromProfile(content); for (int i = 0; i &lt; names.Count; i++) { namesAndTexts.Add(names[i] + " " + texts[i]); } if (InvokeRequired) { for (int f = 0; f &lt; namesAndTexts.Count -1; f++) { BeginInvoke(new Action(() =&gt; textBox1.AppendText(namesAndTexts[f])), null); } } reader.Close(); response.Close(); Thread.Sleep(1000); } } } </code></pre> <p>I tried this part:</p> <pre><code>if (InvokeRequired) { for (int f = 0; f &lt; namesAndTexts.Count -1; f++) { BeginInvoke(new Action(() =&gt; textBox1.AppendText(namesAndTexts[f])), null); } } </code></pre> <p>But its not working good its keeping adding the list over and over to the textBox. I want in the textbox to see it as:</p> <blockquote> <p>daniel hello</p> <p>yaron bye</p> <p>danny good</p> </blockquote> <p>And only once.</p> <p>Another thing is if in the For im not doing <code>namesAndTexts.Count - 1</code> but <code>namesAndTexts.Count</code> then its throwing me error exception the namesAndTexts[f] that the index should not be less then zero but less then the list....</p> <hr> <p>After this will work I need to check if the List is changed and make somehow automatic push up in the textBox lets say to fill the textBox to its size with lines and when its getting to the bottom start scroll up and keep update the new lines only from the bottom abnd push the old ones up from the top.</p> <p>How can i do it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload