在一列中插入10行,在另一列中插入10行,依此类推......在c#中的winform中 [英] insert 10 rows in one column and next 10 in another column and so on...in winform in c#
问题描述
我有一个超过100行的表(单列),我希望在窗口中显示所有控件(比如数据网格视图)一行中的10行和另一列中的下一行10,依此类推。我认为没有办法做到这一点。
说:
1 11 21
2 12 22
3 13 23
4 14 24
5 15 25
6 16 26
7 17 27
8 18 28
9 19 29
10 20 30等......
I have a table of more than 100 rows(single column), and i want display all in windows form any control(say data grid view) 10 rows in one column and next 10 rows in another column and so on. I think there is no way to do that.
Say:
1 11 21
2 12 22
3 13 23
4 14 24
5 15 25
6 16 26
7 17 27
8 18 28
9 19 29
10 20 30 and so on......
推荐答案
你好,
你应该循环你的数据来创建列和行
检查这个例子,希望它会帮助:
来创建数据网格列:
Hello,
you should loop your data to create the columns and rows
check this example, hope it will help :
to create the data grid columns :
int counter = 10;// counter
int kk = 100 / 10;// 100 is your data lenght
for (int k = 0; k < kk; k++)//loop your data
{
dataGridView1.Columns.Add(k.ToString(),k.ToString());//add the columns
}
或
Or
int counter = 10;// counter
for (int k = 0; k <= 100; k++)//loop your data
{
if (k == counter)
{
counter += 10;
dataGridView1.Columns.Add(k.ToString(), k.ToString());//add the columns
}
}
填空行:
Fill empty rows :
for(int i =0;i<10;i++)
dataGridView1.Rows.Add();// add 10 empty rows
添加数据:
Add the data :
for (int i = 0; i < 100; i++)//loop data again
{
dataGridView1.Rows[ct].Cells[counter].Value = i;//fill data
ct++;
if (ct == 10)//when ct ==10 go to next columns
{
ct = 0;
counter++;
}
}
这篇关于在一列中插入10行,在另一列中插入10行,依此类推......在c#中的winform中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!