I need to fill the lines of a multiline TextBox with the contents of a ListArray.
I have a TextBox on a form, with properties set as follows:
Name = txtErrors
MultiLine = true
AcceptsReturn = true
AcceptsTab = true
In my code, I do the following:
private
ArrayList myErrorList = new ArrayList(100);// The array is filled elsewhere with error messages
txtErrors.Lines = new string[myErrorList.Count];myErrorList.CopyTo(txtErrors.Lines);
My code compiles, but the multiline text box is empty, although the myErrorList ArrayList has 3 entries in it (as seen during debugging). Why isn't this working
J.

Why doesn't this work?!
ItayItsMe
Thank you very much, it's working now.
Can you please explain why
Thanks again,
J.
Euclidez
well you are going through each element of the array, the array containing the values, so when you go through each element of the array, you are getting the value and appending to the textbox following by a newline.
the CopyTo copies the array collection into another array, which may/may not work - it's just better doing it as above so you know exactly what's going on
Paul Stovell
try this way
foreach(string currentElement in myErrorList)
{
this.txtErrors.Text += currentElement + Environment.NewLine;
}