Value of '11608' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'. Parameter name:Value'

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
Error occur when display data on the DataGridView of the UserControl like following.

Value of '11608' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'. Parameter name:Value'

Here is the code snippet.(gridConversationMessages is DataGridView)

if (keepRowIndex >= 0)
gridConversationMessages.FirstDisplayedScrollingRowIndex = keepRowIndex; // Error occur !

This error doesn't occur when keepRowIndex is small value, for example, when it is 46.

However error occur when it is bigger value, for example, when it is 100.

According to the explanation of MSDN, this exception handling occurs from DataGridView's FirstDisplayedScrollingRowIndex when ..... Here is the comment from MSDN.

ArgumentOutOfRangeException
The specified value when setting this property is less than 0 or greater than the number of rows in the control minus 1.

If I check the both value, lvalue is always smaller 1 than rvalue like following.

gridConversationMessages.Rows.Count = 47, keepRowIndex = 46 // No error

gridConversationMessages.Rows.Count = 101, keepRowIndex = 100 // Error occur


Can anybody give me any idea about this error?

Continue reading...
 
Back
Top