General information
Title:
ColumnChanged-ColumnChanging
I have a datagrid bounded to a datatable in which i process orderdetails, i want to calculate each time i change price or quantity the total column value, that works with the following code only when i press the keydown key and inserts a new line behaviour that i want to avoid, i want to change the total column value and the total orders amount each time i change quantity or price value remaining in the same row
Another problem i 'm having is that it does not recalculate the total order's amount as i intend in the total () method after changing the columns value.
Private Sub Column_Changed(ByVal sender As Object, ByVal e As DataColumnChangeEventArgs)
If e.Column.ColumnName = "precio" Or _
e.Column.ColumnName = "cantidad" Then
Dim stot As Decimal
stot = Convert.ToDecimal(e.Row("precio")) * _
Convert.ToDecimal(e.Row("cantidad"))
e.Row("Total") = stot
e.Row.EndEdit()
End If
Me.total()
End Sub
Sub total()
Dim decTotal As Decimal
decTotal = Convert.ToDecimal(ds.Tables("movdet").Compute("sum(Total)", "cantidad<>0"))
Me.TxtTotal.Text = Format(decTotal, "#,###,##0.00")
End Sub
Thank's in advance for your help.
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only