2

I have an array that is populated by an SQLDataReader. The SQL statement generates a list of numbers, for this example, the numbers are 1 through 6. This can increase or decrease depending on the data. For instance, tomorrow, the values could be 5 through 13.

For QA purposes, I'd like to list the array contents horizontally in a listbox that displays other application QA info in realtime. At the moment, I can list the data vertically by looping in the SQLDataReader. The text appears in the listbox like this:

1
2
3
4
5
6

I'd like the data to look like this.

1 2 3 4 5 6

It should not be in columns as there are other text lines that are sent to the list box. Note, I've placed spaces for readability. The final output would appear like this:

"The check array contents are: 1 2 3 4 5 6"

I know how to do this using the Console but I've not been able to do this with the listbox. Here is my listbox code:

SQLDataReader Preamble....
Int32[] streamArray = (from IDataRecord r in reader1 select (Int32)r["streamID"]).ToArray();
for (int = 0; i < idCount; i++)
{
   listbox1.Items.Add(streamArray[i];
}

The purpose for this is QA. The app does quite a bit with different arrays. The readability becomes difficult with large numbers of arrays dumping their contents vertically.

Thank you for the help.

1 Answer 1

1
listbox1.Items.Add(string.Format("The check array contents are: {0}", string.Join(" ", streamArray)));
Sign up to request clarification or add additional context in comments.

2 Comments

Wow that was fast. This works! I would vote it as an answer but I don't have enough rep yet. Thank you very much! As a note, there is a missing parentheses at the end. It should be: listbox1.Items.Add(string.Join(" ", streamArray));
@user3507825 your welcome, you right I missed one parenthesis, also remember this will concatenate all the numbers and adding them as one item.so you can't access them seperately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.