Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
example as follows in datagridview;


RK Mk CK VK Gs VB CNN UNNI SK Total (column name)

REO PH2 MFA CTF TFC LSG Tasco HK MK 9

REO PH2 TASCO TFC LGTF ECDIS MFA CTF TFC 9


i want each row wise total.

output i want as follows

1st row total 9
2nd row total 9

9 to be displayed in the total column.how can i get the total each row wise.

for that how can i do.

it is w windows applciation.
Posted
Comments
Jibesh 2-Feb-13 3:38am    
are you using any database binding? if yes you can do that in your query.
one more question
do you want the count to update dynamically when the user edit the cell value of that row?
[no name] 2-Feb-13 5:46am    
i did not save the total row in database. but when user edit the cell value of that row that time count to be update.

if you want do it like this

1.create rowcreated event of gridview
2. sum desired columns of griview
3.bind it in desired row location in grid view
you are done

if u can not do this reply for tested code
 
Share this answer
 
v2
Store the datasource of the datagridview in a list, then just count how many items you have in the list.

C#
List<string> list = dataGridView1.DataSource;
int numberOfItems = list.Count();</string>
 
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