I have a Datagridview in my C# program that contain numeric data.
I need to sum all column A and all column B.
(I don’t want to use any SQL queries.)
How Do I do this?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
gridView.DataSource. It can be either an IList Interface or an IListSource Interface which has a methodGetList()that returns anIList. So you can basically run a summing method on it’s members.Or if you know the exact type in DataSource, you can aggregate the data using specific methods of the object in there (even use the Enumerable.Sum Method if possible).
or