We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to change a column as a result of changing another column

In a grid, I need to manually recalculate two other columns after manually changing one column.
how can you do it in vb.net

my code is 

 Private Sub Grelha_TableControlCurrentCellValidated(sender As Object, e As GridTableControlEventArgs) Handles Grelha.TableControlCurrentCellValidated
        Dim dComissaoEmpresa As Double = 0

        Select Case ccTipo
            Case tipo.Agentes

                ' CELULA ONDE ESTOU
                Dim currentCell As GridCurrentCell = Me.Grelha.TableControl.CurrentCell
                Dim tableCellStyle As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(currentCell.RowIndex, currentCell.ColIndex)

                If Not IsNothing(tableCellStyle.TableCellIdentity.Column) Then
                    Dim r As Record = Grelha.Table.CurrentRecord
                    Select Case tableCellStyle.TableCellIdentity.Column.Name
                        Case "Perc." ' - nome da coluna em que estou

                            Dim dPerc As Double = r.GetValue("Perc.") -> that's my problem. it brings the old value not the value that i put in the column

                            dComissaoEmpresa = r.GetValue("Com. Empresa")
                            r.SetValue("Vl. Comissão", dComissaoEmpresa * dPerc / 100)
                            r.SetValue("Vl.Restante", dComissaoEmpresa - (dComissaoEmpresa * dPerc / 100))
                        Case "Vl. Comissão" ' 
                        Case "Vl.Restante"
                        Case Else
                    End Select

                End If
            Case Else
        End Select
    End Sub
End Class

3 Replies

AR Arulpriya Ramalingam Syncfusion Team August 27, 2019 07:56 AM

Hi Ricardo, 
Thanks for using Syncfusion products. 
In order to perform some computation in a column based on other columns values, the ExpressionFields can be added to the GridTableDescriptor. We already documented the details to use ExpressionFields in GridGroupingControl. Please make use of the below UG link. 
Please revert us with simple screenshot of your requirement, if we misunderstood your scenario. 

RA Ricardo Abranches September 3, 2019 09:10 AM

Hello and thanks. The link you send explains what i need.
Thanks , and keep on the good work.

AR Arulpriya Ramalingam Syncfusion Team September 4, 2019 12:04 AM

Hi Ricardo, 
Thanks for the update. 
We are glad to know that the reported use case is resolved at your end and we are happy to assist you. 

Live Chat Icon For mobile
Up arrow icon