c# - Result of two multipled columns in a datagridview row -


i have got code calculates summary of 2 multiplied columns of rows in datagridview , shows result in textbox.

i have got third column called sum in show particular result of each row. i'm sorry because have no idea how can that, haven't tried yet. may please show me way?

thanks time,comments or answers.

private void vypocti_odvody(int price, int vat, int tot_rows2)     {         try         {          double outval = 0;         foreach (datagridviewrow row in datagridview1.rows)          {             outval = outval + (convert.todouble(row.cells[price].value)/100) * convert.todouble(row.cells[vat].value) + (convert.todouble(row.cells[price].value));         }       //   s_ub_celk.text = (((a / 100) * b) + a).tostring();         convert.todecimal ( result.text = outval.tostring()) ;     }     catch (exception ex)     {         messagebox.show("chybové hlášení k3 " + ex.message.tostring());     }   } 

you can give value column assigning it's value property:

private void vypocti_odvody(int price, int vat, int tot_rows2)     {         try         {         double outval = 0;         foreach (datagridviewrow row in datagridview1.rows)         {             double localsum = (convert.todouble(row.cells[price].value)/100) * convert.todouble(row.cells[vat].value) + (convert.todouble(row.cells[price].value));             outval = outval + localsum;             row.cells[sumcolumn].value = localsum;         }         convert.todecimal ( result.text = outval.tostring()) ;     }     catch (exception ex)     {         messagebox.show("chybové hlášení k3 " + ex.message.tostring());     } } 

just substitute sumcolumn name.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -