开发者

vb.net keyup event

I have a datagridview having 3 columns (qty,scraft factor,actuall qty). What I want is if the user encode 50 in qty and 2 in scraf factor, actuall qty will automatically comp开发者_开发技巧uted based on qty multiply by 2. I was using keyup event. Now I am using endedit to get the current value of the current row and column, now the problem is if the amount to be encoded is more than one digit it will not accept because of endedit. What event do I have to used? or any solution with this scenario. Please see the code below

thanks in advance.

tirso

Private Sub tbx_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    dgvIngredient.EndEdit()

    Dim intCurrentRow As Integer = dgvIngredient.CurrentRow.Index
    Dim decQuantity As Decimal
    Dim decScrafFactor As Decimal
    Dim decActuallQty As Decimal

    decQuantity = dgvIngredient.Item(2, intCurrentRow).Value
    decScrafFactor = dgvIngredient.Item(3, intCurrentRow).Value
    decActuallQty = decQuantity * decScrafFactor

    dgvIngredient.Item(4, intCurrentRow).Value = decActuallQty

End Sub


For me it works without problems in the CellEndEdit event.

Try this (all in 1 step):

dgvIngredient.Rows(e.RowIndex).Cells(4).Value = Convert.ToDecimal(dgvIngredient.Rows(e.RowIndex).Cells(2).Value) * Convert.ToDecimal(dgvIngredient.Rows(e.RowIndex).Cells(3).Value)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜