I am writing a socket client *Form Application*. i want to display message we sent and received in an area to monitor the communication. is the ListBox a right component for this purpose?
EDIT:
Why the ListBox display is not line by line but only showing at the end? the TextBox is showing new text each time.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->listBox1->MultiColumn = true;
for(int i = 0; i <10; i++)
{
this->textBox1->AppendText(String::Format( "Item {0}", i ));
this->listBox1->BeginUpdate();
this->listBox1->Items->Add( String::Format( "Item {0}", i ));
listBox1->EndUpdate();
Sleep(500);
}
}
I was thinking use label but cannot find a scrolling control with it.
This is the first time I use Form Application. Please be patient.
I always use a TextBox control, set it to multiline and prepend, rather than append the new lines. This way the most recent text is always on top and you don’t have to worry about scrolling. You can do the same with a label control, too, but you lose the ability to scroll down.
If course, depending on how long-running this is, you may need to clean up instead of just keeping all the text indefinitely. You’ll run into memory issues if you do keep all of the text indefinitely.