Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: Show panel after a job is completed Pin
Pablo Bozzolo29-Feb-16 9:16
Pablo Bozzolo29-Feb-16 9:16 
GeneralRe: Show panel after a job is completed Pin
Mycroft Holmes29-Feb-16 11:56
professionalMycroft Holmes29-Feb-16 11:56 
GeneralRe: Show panel after a job is completed Pin
Richard MacCutchan29-Feb-16 10:42
mveRichard MacCutchan29-Feb-16 10:42 
AnswerRe: Show panel after a job is completed Pin
Luc Pattyn29-Feb-16 17:30
sitebuilderLuc Pattyn29-Feb-16 17:30 
AnswerRe: Show panel after a job is completed Pin
BillWoodruff1-Mar-16 1:00
professionalBillWoodruff1-Mar-16 1:00 
QuestionConditional Mathematical Statements Pin
Member 1226553728-Feb-16 21:39
Member 1226553728-Feb-16 21:39 
AnswerRe: Conditional Mathematical Statements Pin
Pete O'Hanlon28-Feb-16 22:08
mvePete O'Hanlon28-Feb-16 22:08 
AnswerRe: Conditional Mathematical Statements Pin
Sascha Lefèvre28-Feb-16 22:09
professionalSascha Lefèvre28-Feb-16 22:09 
You have to write the code yourself that does the calculation you want. You're probably setting the DataSource of your DataGridView to a DataTable, right? Use that DataTable also for your calculations. It's more convenient to handle than a DataGridView.

There are two options:

The traditional way: Loop over the rows in the DataRow-collection of the DataTable, read the values of the columns that are required for your calculation and then do the actual calculation. This would be a sample where I assumed double as the data type of your column "H1" and "some integer type" for the "Analyzer"-column:
C#
double analyzer1Sum = 0;
int analyzerColumnIndex = myDataTable.IndexOf("Analyzer");
int h1ColumnIndex = myDataTable.IndexOf("H1");
foreach(DataRow row in myDataTable.Rows)
{
   if(row[analyzerColumnIndex] == 1)
   {
      analyzer1Sum += row.Field<double>(h1ColumnIndex);
   }
}


The LINQ way (assuming double as the data type of your column "H1" and int for the "Analyzer"-column):
C#
int analyzerColumnIndex = myDataTable.IndexOf("Analyzer");
int h1ColumnIndex = myDataTable.IndexOf("H1");
double analyzer1Sum = myDataTable.AsEnumerable()
                                 .Where(row => row.Field<int>(analyzerColumnIndex) == 1)
                                 .Select(row => row.Field<double>(h1ColumnIndex))
                                 .Sum();

If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson


modified 29-Feb-16 13:49pm.

Questionicon/image in datagridview Pin
Any_name_at_all28-Feb-16 1:52
Any_name_at_all28-Feb-16 1:52 
AnswerRe: icon/image in datagridview Pin
Dave Kreskowiak28-Feb-16 4:25
mveDave Kreskowiak28-Feb-16 4:25 
GeneralRe: icon/image in datagridview Pin
Any_name_at_all28-Feb-16 5:52
Any_name_at_all28-Feb-16 5:52 
QuestionHow does Observable.Join work? Pin
Kenneth Haugland27-Feb-16 18:38
mvaKenneth Haugland27-Feb-16 18:38 
AnswerRe: How does Observable.Join work? Pin
Kenneth Haugland28-Feb-16 12:15
mvaKenneth Haugland28-Feb-16 12:15 
SuggestionRe: How does Observable.Join work? Pin
John Torjo28-Feb-16 18:44
professionalJohn Torjo28-Feb-16 18:44 
GeneralRe: How does Observable.Join work? Pin
Kenneth Haugland28-Feb-16 19:13
mvaKenneth Haugland28-Feb-16 19:13 
GeneralRe: How does Observable.Join work? Pin
John Torjo28-Feb-16 19:17
professionalJohn Torjo28-Feb-16 19:17 
GeneralRe: How does Observable.Join work? Pin
Kenneth Haugland29-Feb-16 18:40
mvaKenneth Haugland29-Feb-16 18:40 
GeneralRe: How does Observable.Join work? Pin
John Torjo29-Feb-16 19:40
professionalJohn Torjo29-Feb-16 19:40 
QuestionGrid View Filtering Pin
Member 1235559027-Feb-16 3:07
Member 1235559027-Feb-16 3:07 
AnswerRe: Grid View Filtering Pin
Afzaal Ahmad Zeeshan27-Feb-16 4:09
professionalAfzaal Ahmad Zeeshan27-Feb-16 4:09 
Questionwhy password is not decrypting Pin
Veena Hosur25-Feb-16 23:13
Veena Hosur25-Feb-16 23:13 
AnswerRe: why password is not decrypting Pin
Richard MacCutchan26-Feb-16 0:20
mveRichard MacCutchan26-Feb-16 0:20 
GeneralRe: why password is not decrypting Pin
Veena Hosur26-Feb-16 0:52
Veena Hosur26-Feb-16 0:52 
GeneralRe: why password is not decrypting Pin
Richard MacCutchan26-Feb-16 0:55
mveRichard MacCutchan26-Feb-16 0:55 
GeneralRe: why password is not decrypting Pin
Nathan Minier26-Feb-16 1:25
professionalNathan Minier26-Feb-16 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.