Hi guys,
I am developing a winform application that contains a couple of
datagridview a tab control.
One of the datagridview has some frozen columns and then a bunch of
dynamic columns created after that. These dynamic columns created
based on number of years ( 2 columns per year).
I want the datagrid to scroll directly to the current year so that the
older years are hidden and that users don't have to scroll the grid to
see the current year.
Everything is working okay, the auto-scrolling is working fine, except
when I close the form, I get the following JIT-exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index

Earlier I was not able to figure out the problem, but after some
research, I found out that the following line of code is giving the
error.

Me.MyDatagridlayedScrollingColumnIndex = FirstVisibleColumnIndex

I double checked that my FirstVisibleColumnIndex is greater than my
frozen columns and less then the total number of columns.

When I commented this line, everything is working fine, I am not
getting the JIT exception.

Please suggest what could be the possible problem and what should I do
to resolve it? Thank you.

Reply via email to