I have define static fee amount you should use your actual columns.
Public Class Form12
Public oCn As New System.Data.SqlClient.SqlConnection("Data Source=(local);Initial Catalog=MyDatabase;Uid=sa")
Dim dv As New DataView
Private Sub Form12_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
fill_grid()
End Sub
Sub fill_grid()
If oCn.State = ConnectionState.Closed Then
oCn.Open()
End If
Me.DataGridView1.Rows.Clear()
Dim cmd As New SqlClient.SqlCommand("SELECT * from mst_scheme", oCn)
Dim da As New SqlClient.SqlDataAdapter(cmd)
Dim ds As New DataSet("bpl")
Dim i As Integer = 0
da.Fill(ds, "bpl")
If ds.Tables(0).Rows.Count > 0 Then
While (i <> ds.Tables(0).Rows.Count)
Me.DataGridView1.Rows.Add()
Me.DataGridView1.Item(0, i).Value = i + 1
Me.DataGridView1.Item(1, i).Value = ds.Tables(0).Rows(i).Item("scheme_name").ToString
Me.DataGridView1.Item(2, i).Value = 1000
Me.DataGridView1.Item(4, i).Value = Me.DataGridView1.Item(2, i).Value - Me.DataGridView1.Item(3, i).Value
i = i + 1
End While
End If
End Sub
Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If Me.DataGridView1.Rows.Count > 0 Then
If e.ColumnIndex = 3 Then
Me.DataGridView1.Item(4, e.RowIndex).Value = Me.DataGridView1.Item(2, e.RowIndex).Value - Me.DataGridView1.Item(3, e.RowIndex).Value
End If
End If
End Sub
End Class