Hey, i trying to list out all the items after i split it in text box. But, the output always list items in wrong way. Can someone help me?

For example:

the output i want to print in the textbox is like this
1
2
3
4
5

but it always give me like this
1 2 3 4 5

The properties for that text box i set true for Multi line.
Here is my coding

SplitItems = (str).Split(new string[] { " ", "\n", "\r", "\t" }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string listOut in SplitItems)
                    {
                        ListSplitItems += "\n" + listOut;
                    }
                    textBox7.Text = ListSplitItems;

why still cannot print out vertically in text box..?
Someone can help me..?

Do you want to use a MultiLine textBox? If so, here is your answer:

public Form1()
        {
            InitializeComponent();
            textBox1.Multiline = true;
            textBox1.ScrollBars = ScrollBars.Vertical;
            Method();
        }

        private void Method()
        {
            int[] array = { 1, 2, 3, 4, 5 };
            foreach (int value in array)
                textBox1.AppendText(value.ToString() + Environment.NewLine);
        }

Hope it helps,
Mitja

but it will add one space in front of the first items and add one space after the last items..how to solve this..?

No it wont, unless if you have a whitespaces on both ends of the string. My upper code for sure does not have those white spaces. Double check your code for white spaces. If they are, remove them (or code will not insert them into a listBox).

btw, Where from you get that string?

This article has been dead for over six months. Start a new discussion instead.