this is the exception
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Main Topics
Browse All Topicscell click return exception, but seletced row doesn't (datagridview)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Private Sub dgvShowBooks_CellClick(ByV
if e.RowIndex > 0 then
txtBookName.Text = dgvShowBooks.Rows(e.RowInd
txtAuthors.Text = dgvShowBooks.SelectedRows(
txtPublishers.Text = dgvShowBooks.SelectedRows(
DatePublished.Text = dgvShowBooks.SelectedRows(
ckbHold.Checked = dgvShowBooks.SelectedRows(
'store values
BookISBn = dgvShowBooks.Rows(0).Cells
currentBookTimestamp = dgvShowBooks.Rows(0).Cells
If dgvShowBooks.SelectedRows(
' ***************** NEED TO PROVIDE A DEFAULT IMAGE FOR EMPTY IMAGES
Else
'read image converitng a byte array to an image
PictureBox.Image = workWithImage.ByteToImage(
End If
end if
End Sub
changed a bit the code.. but does not work
Private Sub dgvShowBooks_CellClick(ByV
txtBookName.Text = dgvShowBooks.SelectedRows(
txtAuthors.Text = dgvShowBooks.SelectedRows(
txtPublishers.Text = dgvShowBooks.SelectedRows(
DatePublished.Text = dgvShowBooks.SelectedRows(
ckbHold.Checked = dgvShowBooks.SelectedRows(
'store values
BookISBn = dgvShowBooks.Rows(e.RowInd
currentBookTimestamp = dgvShowBooks.Rows(e.RowInd
If dgvShowBooks.SelectedRows(
' ***************** NEED TO PROVIDE A DEFAULT IMAGE FOR EMPTY IMAGES
Else
'read image converitng a byte array to an image
PictureBox.Image = workWithImage.ByteToImage(
End If
End Sub
FULL WORKING CODE
Private Sub dgvShowBooks_CellClick(ByV
If e.RowIndex > 0 Then
txtBookName.Text = dgvShowBooks.Rows(e.RowInd
txtAuthors.Text = dgvShowBooks.Rows(e.RowInd
txtPublishers.Text = dgvShowBooks.Rows(e.RowInd
DatePublished.Text = dgvShowBooks.Rows(e.RowInd
ckbHold.Checked = dgvShowBooks.Rows(e.RowInd
'store values
BookISBn = dgvShowBooks.Rows(e.RowInd
currentBookTimestamp = dgvShowBooks.Rows(e.RowInd
If dgvShowBooks.Rows(e.RowInd
' ***************** NEED TO PROVIDE A DEFAULT IMAGE FOR EMPTY IMAGES
Else
'read image converitng a byte array to an image
PictureBox.Image = workWithImage.ByteToImage(
End If
End If
End Sub
Business Accounts
Answer for Membership
by: brilloxPosted on 2007-02-16 at 14:27:31ID: 18552571
this is the code that I use (below)
al sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lEventArgs ) Handles dgvShowBooks.CellClick
ex).Cells( 0).Value
0).Cells(" Authors"). Value 0).Cells(" Publisher" ).Value 0).Cells(" Date").Val ue 0).Cells(" IsOnHold") .Value
("BookISBN ").Value ("BookTime Stamp").Va lue
0).Cells(" Image").Va lue Is DBNull.Value Then
dgvShowBoo ks.Selecte dRows(0).C ells("Imag e").Value)
basically If I select the row, it work fine, but if I click on a single cell it return an exception
Private Sub dgvShowBooks_CellClick(ByV
txtBookName.Text = dgvShowBooks.Rows(e.RowInd
txtAuthors.Text = dgvShowBooks.SelectedRows(
txtPublishers.Text = dgvShowBooks.SelectedRows(
DatePublished.Text = dgvShowBooks.SelectedRows(
ckbHold.Checked = dgvShowBooks.SelectedRows(
'store values
BookISBn = dgvShowBooks.Rows(0).Cells
currentBookTimestamp = dgvShowBooks.Rows(0).Cells
If dgvShowBooks.SelectedRows(
' ***************** NEED TO PROVIDE A DEFAULT IMAGE FOR EMPTY IMAGES
Else
'read image converitng a byte array to an image
PictureBox.Image = workWithImage.ByteToImage(
End If
End Sub