Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 1-Feb-13 19:54pm
Comments
jibesh at 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?
Member 8054539 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Store the datasource of the datagridview in a list, then just count how many items you have in the list.
 
List<string> list = dataGridView1.DataSource;
int numberOfItems = list.Count();</string>
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100