Why DataGridViewTextBoxCell showing output of previous input in DataGridView

100 Views Asked by At

I am working with- window application, VB, VS 2012, .net F/W- 4.5
I have a DGV (datagridview) in form. There are different types of column (dgv-combobox, dgv-textbox) in DGV which are created runtime.

Code: textchanged event (runtime created using addhandler) of DataGridViewTextBoxCell

 Private Sub txt_box_textchanged(sender As Object, e As EventArgs)
        Dim a, b, total_price As Int32
        a = dgv.Rows(0).Cells(3).Value
        b = dgv.Rows(0).Cells(4).Value
        total_price = a * b
        dgv.Rows(0).Cells(5).Value = total_price
 End Sub

Screenshot of DGV inputs:
If I change input value (any of textbox- a or b), it does not affect on output.
In other words, output is not as it should be, like 5*3=15, 4*9=36
But if I change cell and change value of that cell, then output will be of previous input (when last time cell got changed).
Otherwise output remains same until input is coming from same cell.
what I mean by "change cell " is click on any other cell of DGV except current cell.
Please note that all row in image are individual input (only one row- not multiple row of DGV).

I also tried "key up" event of textbox using same code, but same issue. Please guys help me to overcome this issue.

0

There are 0 best solutions below