[RESOLVED] Datagridview on cell leave Refresh problem
I want to send the data that i just entered into a cell to an If-statemens to perform certain functions.
I an using the following code just for testing purposes:
1 Code:
Private Sub DGVReceipt_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVReceipt.CellLeave
Dim row, cell As Integer
row = e.RowIndex
cell = e.ColumnIndex
Dim a As String
a = DGVReceipt.Item(cell, row).Value
End Sub
Now I find that the value I entered into the cell doesn't display. Only when i go back to the cell and leave it again will it display.
How can I get the value to display immediately?
Re: Datagridview on cell leave Refresh problem
I don't see how that code can do anything useful. You assign the cell value to a local variable that immediately loses scope. You aren't changing anything.
Re: Datagridview on cell leave Refresh problem
I played with the code some more and got it to do what i wanted.
vb Code:
Private Sub DGVReceipt_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVReceipt.CellLeave
Dim row, cell As Integer
row = e.RowIndex
cell = e.ColumnIndex
DGVReceipt.CommitEdit(DataGridViewDataErrorContexts.Commit)
Dim strNewValue As String
strNewValue = DGVReceipt.Item(cell, row).Value
Dim totrows As Integer = DGVReceipt.Rows.Count - 1
Select Case cell
Case Is = 0 And row < totrows '\\\\ CATEGORY
Case Is = 1 And row < totrows '\\\\ STOCK
If DGVReceipt.Item(cell, row).Value = "-- Add New --" Then
frmNewStock.ShowDialog()
STOCK_DROPMENU()
End If
Case Is = 2 And row < totrows '\\\\ ESTATE
End Select
End Sub
Re: [RESOLVED] Datagridview on cell leave Refresh problem
Hello guys!
I am facing similar kind of problem with the Datagridview, I am trying to validate a certain column, and when I check on a value right after I leave the cell, I am not getting the current value, any pointers on this?
--Vatsa