none
Adding the values of cells across a row and display result in another cell RRS feed

  • Question

  • Hi gurus in the house! Is it possible to add all the cell values along a particular row and put the result in another column in Datagridview? If yes, how do I go about that in VB.net please?

    I have the following coulmns in the datagridview; TOTAL SCORE, CA, Q1, Q2, Q3

    So what i want to do is, when the user enters a number, immediately the user leaves each cell of the current row

    then it's added automatically to the "TOTAL SCORE" column depending on the row in which the current operation is being performed. In other words, each row will be working independent of another row.

    In my case, i want add up the values in column CA, Q1, Q2, Q3 and populate the result in Total Score column. But this operation will be done for row 0 on the leave event of each of the involved cells in the above columns.

    I plead with the gurus in the house to help out. Any idea is accepted.

    Thanks!!!

    Thursday, May 25, 2017 9:30 AM

Answers

  • One way to do this is with a DataTable (which would be set to the DataSource of the DataGridView) where the total DataColumn has the Expression property set to total the columns yet there can be some underlying issues so the next step up from there is to use DataTable events as in this sample.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Pat Nadis Thursday, May 25, 2017 5:24 PM
    Thursday, May 25, 2017 10:13 AM
    Moderator

All replies

  • One way to do this is with a DataTable (which would be set to the DataSource of the DataGridView) where the total DataColumn has the Expression property set to total the columns yet there can be some underlying issues so the next step up from there is to use DataTable events as in this sample.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Pat Nadis Thursday, May 25, 2017 5:24 PM
    Thursday, May 25, 2017 10:13 AM
    Moderator
  • Thanks so much for that idea Kareninstructor. Your idea worked for me.

    Thumbs Up

    Thursday, May 25, 2017 5:27 PM