Hi guys, I want to multiply or add the values of two or more cells in a datagridview control in a row and and should also be auto-saved in the database after entering datas in the cell. I am using SQL Server 2008 for my database.
Please do take a look at the screenshot attachment that I made for further details..
I don't know what code to use, so I did not put any codes in this discussion.
Dim iCell1 As Integer
Dim icell2 As Integer
Dim icellResult As Integer
iCell1 = DataGridView1.CurrentRow.Cells(1).Value
icell2 = DataGridView1.CurrentRow.Cells(2).Value
icellResult = iCell1 * icell2
DataGridView1.CurrentRow.Cells(3).Value = icellResult
Catch ex As Exception
Make sure the selectionMode is set to cellSelect. Once user leaves the cell 3 it will get the calculated values in it.
i tried code to calculate coloumn total amount and reach coloumn amount paid
If dgv.RowCount > 1 Then
Dim amount As Decimal = 0
For index As Integer = 0 To dgv.RowCount - 1
amount += Convert.ToDecimal(dgv.Rows(index).Cells(3).Value)
TextBox1.Text = amount
i reached this code after search but with this i only sum the last coloumn values into textbox like you did but i need to sum data from item amount and quantity and in the same time get sum of data in in textbox
hope this code help you
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...