how to set focus to data gridView cell and gets the value to use it later.

salbouq1

New member
Joined
Jul 31, 2011
Messages
1
Programming Experience
10+
the question as follow, I have a barcode device that reads the product code and then records it in the first row and first column. when the reading is finished, I want to
get this value from the cell and write sql to retrieve the info from the DB and then populated in the rest of the field.

and example :
assume we have

step 1:
- when the barcode reads code
itemId -------- itemName ------- itemType
123456
------------------------------------------


step 2:
- access row (0) in column 0 and write sql retrieve all the info to be populated
itemId -------- itemName ------- itemType
123456 phone card stc
------------------------------------------

when the next code is read it records in the second row and do the same as step 2


1- is there any idea better that what I did even though both are not working and gave me null values and I could not find way to access the
value


Dim count As Integer = 0
Private Sub dgImport_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgImport.LostFocus
MsgBox(CStr(dgImport.Rows(count).Cells(0).Value))
count += 1
End Sub​

2*

Private Sub dgImport_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArg s) Handles dgImport.RowsAdded
MsgBox(CStr(dgImport.Rows(count).Cells(0).Value))
count += 1





 
Back
Top