Click here to Skip to main content
15,902,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I am creating windows application using c# 2010 – here I am using data grid view, my data grid view default height 363, here I want : my data grid view rows 5 only enough, how to control the grid view.
And I am entered 5 rows completed automatically create second columns again 5 rows.

My Colums
Slno	 mts	 cms			Slno	 mts	 cms
1					1	
2					2
3					3
4					4
5					5

How to create above method any one give me ideas.


What I have tried:

How to create second columns after fill our datagridview fixed rows
Posted
Updated 8-Jul-16 7:42am
Comments
[no name] 8-Jul-16 13:00pm    
What do you mean by second column?
Boopalslm 8-Jul-16 13:11pm    
same my first columns display to second columns

my first columns
slno mts cms


how to create give me ideas.
[no name] 8-Jul-16 13:18pm    
On grid validating event you can check the condition that all five rows have value or not once the condition get true you can add the columns with different name and same disply text.
Karthik_Mahalingam 8-Jul-16 13:21pm    
what is "how to control the grid view" ?
what is your datasource?

1 solution

That's a weird requirement really?
We would like to know the actual requirement first so that we will be able to suggest you a better approach.

But if you don't want to consider the above suggestion, you can take help of datatable. Keep the data in the datatable and create another blank datatable. Now run a loop of 5 to fill the second datatable. Your logic should be, first add the required no. of columns and once the first loop gets completed add new columns for filling the next sequence of data. The second loop also starts filling data from 1st row but from the new column and repeat the process till all your rows from first datatable is filled in to the second datatable.

If you find any difficulties or issue while implementing this, please let me know.

Hope, it helps :)
 
Share this answer
 

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