c# - Index out of range exception in datagridview when header is selected -


Text after "div class =" itemprop = "text">

I think that for sorting or for any reason I get a follow-up error on the following line when I click on a title A DataGridView is the code ....

The reason for our exception is the argument (the index was out of bounds. Should be less than the size of the non-negative and the collection. <> Private Zero firearmView_CellClick (Object Sender, DataGridViewCellEventArgs E) {Pre // I get the error above if line above. If (firearmView.Rows [e.RowIndex] .IsNewRow) {selectedFirearmPictureBox.Image = Image. FromFile (firearmView.Rows [e.RowIndex] .cs [12] .Value.ToString (), true);}}

I do not know why I am getting this particular error here.

< P> In the MSDN docs, say about

When RowIndex property returns -1, the cell is either a column header or a line of cells is shared.

So you have to handle E.Roindex == -1 when you do yo event
(... index .... not negative Not Received)

  Private Zero firearmView_CellClick (Object Sender, DataGridViewCellEventArgs e) {if (e.RowIndex == -1) Return; If {selectedFirearmPictureBox.Image = Image.FromFile (firearmView.Rows [e.RowIndex] .cs [12] .Value.ToString (), true) (firearmView.Rows [e.RowIndex] .IsNewRow!); }}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -