Question a general question regarding datagridview

unclewalt

Member
Joined
Dec 8, 2009
Messages
5
Programming Experience
10+
Dear community,

this is a general question - am only looking for an outline of the right way to tackle the problem.

am using an unbound datagridview and am finding it difficult to dynamically modifiy the contents of 1 cell based on an input in another cell.

For example, if a qty is entered in one cell, the requirment is to extract the price from an adjacent cell in the same row and dynamically place the price * extension in the other cell adjacent to the entered qty.

If the user has clicked out of the datagridview entirely, say into a textbox, it's trivial to update the extension correctly. But the problem arises when the user has clicked into a different cell in the datagridview. Any attempt I have made so far to update the extension cell say during the datagridview.cellleave or datagridview.cellvalidating events of the qty cell or during the datagrivew.cellenter event of the newly targeted cell seem to create a cascading series of datagridview events with oftentimes unfortunate results. Seem clear this type of strategy may not be the way to go.

but we would like the user to see the effect of her action (entering or modifying a qty) as soon as she signifies its completion by clicking anywhere else on the form including a different cell of the datagridview.


I feel there must be a logical, straightforward way to tackle this kind of problem but so far the solution eludes me. Neither did browsing the web for a solution seem to help. hoping someone can point this old geezer in the generally right direction before too much time is wasted!

Thanks in advance for any insight.
Uncle Walt
 
You should handle CellValueChanged instead.

VB.NET:
Private Sub dgv_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv.CellValueChanged
    If e.ColumnIndex = dgv.Columns("mycolumn").Index Then
        ' Do something
    End If
End Sub
 

Latest posts

Back
Top