Datagridview error : Value' should be between 'minimum' and 'maximum'

I was trying to populate data in DataGridView control. It was getting populated into it correctly. But when I was trying to scroll down it was throwing an exception like;

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

    at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
       at System.Windows.Forms.DataGridView.ScrollRows(Int32 rowCount, Int32 deltaY, ScrollEventType scrollEventType)
       at System.Windows.Forms.DataGridView.ScrollRowsByCount(Int32 rows, ScrollEventType scrollEventType)

The Dynamic binding was used to fill the Datagridview.

After a lot of debugging and searching this issue got resolved with just one statement.
I called dataGridView1.PerformLayout() after populating data.

Thanks to Google :)


  1. I had the very same proplem with a very same DatatGrid View. Thanks for the solution!

    Target platform: .Net 3.5 in VS2010 Express

  2. Thank you for the soluction, I had 3 days finding why the gridview was not displaying all information.

  3. Thanks a lot for the solution. I got the same error message and was searching very long for a solution. It is a great help.