0

I'm using this to write text back into textbox1, and it works correctly to avoid cross thread operation, but... I only receive a single line of output from it. Any idea how I can do more of an AppendText call rather than a basic text call?

  private void SetText(string text)
    {
        // InvokeRequired required compares the thread ID of the
        // calling thread to the thread ID of the creating thread.
        // If these threads are different, it returns true.
        if (this.textBox1.InvokeRequired)
        {
            SetTextCallback d = new SetTextCallback(SetText);
            this.Invoke(d, new object[] { text });
        }
        else
        {
            this.textBox1.Text = text;
        }
    }
Jacob
  • 77,566
  • 24
  • 149
  • 228
Israel
  • 3
  • 2
  • There is also literally an AppendText() method: `this.textBox1.AppendText(text);` – Idle_Mind Nov 19 '13 at 21:37
  • Thanks, this actually works better for my purpose, since the textbox still initiates the autoscroll with this method. – Israel Nov 20 '13 at 02:46

1 Answers1

1
 private void SetText(string text)
 {
    // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
      // If these threads are different, it returns true.
    if (this.textBox1.InvokeRequired)
      {
        SetTextCallback d = new SetTextCallback(SetText);
        this.Invoke(d, new object[] { text });
     }
    else
     {
         //append  text  like  this  
         this.textBox1.Text += text;
     }
}
BRAHIM Kamel
  • 13,492
  • 1
  • 36
  • 47