franklinan
asked on
URGENT :DataGridView: Update cell content (cell_1) when editing Cell_2, and viceversa.
Hello Experts :
I want to do the following :
I have a datagridview with manual bind to Db, and there are two columns that can be modified. My problem is that I want to update the column_one if column_Two is modified, and I want to update column_Two if user is editing column_one. How to do this ? I ve tried this code and doesnt works :
Private Sub DGridView_CellValueChanged (ByVal sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lEventArgs ) Handles DGridView.CellValueChanged
Dim NomTaula As String = "T_Linies" & Calendari.SelectionRange.S tart.Year. ToString
If e.RowIndex <> -1 Then
Select Case e.ColumnIndex
Case 1 'column_one
If IsNumeric(DGridView.Curren tCell.Valu e) Then
DGridView.CurrentRow.Cells (2).Value = Math.Round((Integer.Parse( DGridView. CurrentRow .Cells(1). Value, Globalization.NumberStyles .Integer) * 100) / DGridView.CurrentRow.Cells (3).Value, 0)
End If
Case 2 ' Column_two
If IsNumeric(Integer.Parse(DG ridView.Cu rrentCell. Value, Globalization.NumberStyles .Integer)) Then 'And DGridView.CurrentCell.Styl e.BackColo r = Color.Orange Then
DGridView.CurrentRow.Cells (1).Value = Math.Round((CInt(DGridView .CurrentRo w.Cells(3) .Value) * CInt(DGridView.CurrentRow. Cells(5).V alue)) / 100, 0)
End If
End Select
End If
End Sub
This code DOES NOT works because the application enters on a bucle, if I modify the column_one, the column_two is updated but the event is fiered again (because column_one has been modifed...)
Any idea please ? ?
I want to do the following :
I have a datagridview with manual bind to Db, and there are two columns that can be modified. My problem is that I want to update the column_one if column_Two is modified, and I want to update column_Two if user is editing column_one. How to do this ? I ve tried this code and doesnt works :
Private Sub DGridView_CellValueChanged
Dim NomTaula As String = "T_Linies" & Calendari.SelectionRange.S
If e.RowIndex <> -1 Then
Select Case e.ColumnIndex
Case 1 'column_one
If IsNumeric(DGridView.Curren
DGridView.CurrentRow.Cells
End If
Case 2 ' Column_two
If IsNumeric(Integer.Parse(DG
DGridView.CurrentRow.Cells
End If
End Select
End If
End Sub
This code DOES NOT works because the application enters on a bucle, if I modify the column_one, the column_two is updated but the event is fiered again (because column_one has been modifed...)
Any idea please ? ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER