0

I'm new in C#. I want my data to fill the first column first, and then the data will fill to the next column after filling the first column with user define row. The data will fill the next column when it reaches the row limit. The Rows and Columns are dynamic depends on user input. Thanks Screenshot in the links

Input:

enter image description here

Expected output:

enter image description here

string[] separators = { ",", " " };
int[] row = new int[Convert.ToInt32(textBox1.Text)];
string value = textBox2.Text ;
string[] words = value.Split(separators, StringSplitOptions.RemoveEmptyEntries);

ArrayList val = new ArrayList();
val.Add(value);

foreach (var word in words)
{
    listView1.Items.Add(word);
    listView1.View = View.List;

}
2

1 Answer 1

1

Here is an example to get rows filled based on user input for row count.

string[] separators = { ",", " " };
int rowCount = Convert.ToInt32("2");
string value = "2 5 6 7 8 9 0 2 1 3 4 5 6";
string[] words = value.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string[] rows = new string[rowCount];

for (int i = 0; i < words.Length; i++)
{
    int mod = i % rowCount;
    rows[mod] += words[i] + " ";
}

foreach (string item in rows)
{
    listView1.Items.Add(item);
}

listView1.View = View.List;
Sign up to request clarification or add additional context in comments.

Comments

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.