Automatically copy a column in datagridview from a different column vb.net 2018

0

I'm new to programming. My problem is this:

I have a Datagridview that has 7 columns, in column 3 data entry. These data will be added automatically at the click of a button, simultaneously in column 1 the values will be copied downwards (all this with clicking on the aforementioned button).

                Columna1                                        Columna2                                       Columna3

                0                                                          0+4                                                   4

                4                                                          4+9                                                   9

                13                                                        13+13                                               13

                26                                                        26+10                                               10

                36                                                        36+n                                                   n

As you can see in the table, the value of zero also wishes to enter it and from there, copy the result of column 2 (which adds the values of column1 and column3).

I am using this code that serves me but only for each row; that is, I must press the button every time I enter a value for each cell in column 3 and I also manually copy in column1 the calculated values of column2. Try             Dim length As Decimal             Dim top As Decimal

       For Each fila As DataGridViewRow In DGVBHA.Rows
            If Double.TryParse(CStr(fila.Cells(0).Value), top) = True AndAlso
                    Double.TryParse(CStr(fila.Cells(2).Value), length) = True Then
                fila.Cells(1).Value = length + top



            Else
               fila.Cells(1).Value = ""

            End If



        Next
    Catch ex As Exception

    End Try

I want to automate this process, just by pressing the button once I throw the values in columns1 and 2 from the values entered in column3.

I would greatly appreciate the help you can give me, regards.

    
asked by Diego Armando Herrera 03.12.2018 в 17:18
source

0 answers