A calculated field in an updatable gridview in a winforms application

I have a gridview with three columns. The first two columns contain numbers. I want the third column to be the sum of the two preceding columns. So, if a user enters, or modifies, a value in one of the first two columns, the third column is recalculated.
Who is Participating?
You should then add a oncellchanged event and do your calculation and update the 3rd column
Frans_TruyensAuthor Commented:
Can you give an example? I don't find the Cell changed event of my gridview.
Frans_TruyensAuthor Commented:
This is my code. I would like to fill column 5 with the sum of column4 and column3.
        adp = New OleDb.OleDbDataAdapter(strSQL, GetConnection)
        dsSchenking = New DataSet
        adp.Fill(dsSchenking, "Schenking")
        Me.gridSchenking.DataSource = dsSchenking.Tables("Schenking")
        Me.gridSchenking.Columns("HistoriekDetID").Visible = False
        Dim colTest1 As New DataGridViewComboBoxColumn
        colTest1.Items.Add(GetVertaling("In volle eigendom", pstrTaal))
        colTest1.Items.Add(GetVertaling("In blote eigendom", pstrTaal))
        colTest1.Items.Add(GetVertaling("Met voorbehoud van vruchtgebruik", pstrTaal))
        colTest1.DataPropertyName = "TypeSchenking"
        colTest1.HeaderText = "Type schenking"
        colTest1.Width = 200
        colTest1.DisplayIndex = 0
        Dim colTest2 As DataGridViewColumn
        colTest2 = Me.gridSchenking.Columns(1)
        colTest2.Width = 150
        Dim colTest3 As DataGridViewColumn
        colTest3 = Me.gridSchenking.Columns(2)
        colTest3.Width = 100
        Dim colTest4 As DataGridViewColumn
        colTest4 = Me.gridSchenking.Columns(3)
        colTest4.Width = 100
        Dim colTest5 As DataGridViewColumn
        colTest5 = Me.gridSchenking.Columns(4)
        colTest5.Width = 100
        Dim colTest6 As DataGridViewColumn
        colTest6 = Me.gridSchenking.Columns(5)
        colTest6.Width = 100

Open in new window

Frans_TruyensAuthor Commented:
Could anyone help me?
Frans_TruyensAuthor Commented:
This solved my problem. Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.