Can’t figure out why am I not able to call this line of code?
MsgBox(SAMPLEIDDataGridView.SelectedRows(0).Cells(0).ToString())
I get the following error message:
An unhandled exception of type ‘System.ArgumentOutOfRangeException’ occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
How is that possible if my table is as follows:
ID First Name Last Name
0 Guy TheGuy
1 John Smith
2 Jim Earthworm
3 Nathan Drake
My Table Design is as follows:
ID int 25 0 0 0 0 0 0 0 0 -1 0
First Name varchar 25 0 -1 0 0 0 0 0 latin1 latin1_swedish_ci 0 0
Last Name varchar 25 0 -1 0 0 0 0 0 latin1 latin1_swedish_ci 0 0
You are working with SelectedRows and so if you have no rows selected it will give you that exception!
Try just Rows..