Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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......
Posted
Updated 16-Aug-14 0:43am
v2
Comments
Herman<T>.Instance 12-Aug-14 3:56am    
why you don't wanna use paging? by putting the values aside the relevance cannot be seen
kool15th 12-Aug-14 4:58am    
in paging i can only show one column at a time, but i want atleast 4-5 columns on one page and for rest paging will work.
_Asif_ 12-Aug-14 3:57am    
What have you tried so far?
kool15th 12-Aug-14 5:04am    
in data grid view nothing as not getting what to do...
i have tried loading dynamic textboxes as all the values present in database will be counted and that much textboxes will be created. but now mapping is causing problem.
As further i need a checkbox along each and on its checked will be shown on other control(say listview).

1 solution

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 :
C#
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


C#
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 :

C#
for(int i =0;i<10;i++)
                   dataGridView1.Rows.Add();// add 10 empty rows



Add the data :

C#
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++;
                   }
               }
 
Share this answer
 
v2
Comments
kool15th 17-Sep-14 1:15am    
Thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900