ReoGrid
ReoGrid copied to clipboard
System.ArgumentOutOfRangeException while using vertical scroll bar
Hello Jing, what an amazing piece of software. Best grid-view, -edit & -'have fun with' ever. :)
A little problem occurred while adding some worksheets in the background. The last one 'DC' has only 2 rows, but the max-value of the vertical scroll bar in the active worksheet 'Main' is updated, which has 305 rows. If you scroll now with the mouse-wheel you get this error:

System.ArgumentOutOfRangeException
HResult=0x80131502
Message=Value of '240' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
at unvell.ReoGrid.ReoGridControl.WinFormControlAdapter.set_ScrollBarVerticalValue(Int32 value)
at unvell.ReoGrid.Views.NormalViewportController.ScrollViews(ScrollDirection dir, Single x, Single y)
at unvell.ReoGrid.Worksheet.OnMouseWheel(Point location, Int32 delta, MouseButtons buttons)
at unvell.ReoGrid.ReoGridControl.OnMouseWheel(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseWheel(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at unvell.ReoGrid.ReoGridControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Excel_Test.My.MyApplication.Main(String[] Args) in :line 81
Hope this helps a bit
Thanks, hope ReoGrid helps you. Is there any simple ways to reproduce this bug?
Hi there ... i can try to extract the code & send you a VB project if you want, but this might take some days.
This will show you the issue #178 too. :)
Hi Jing, if you add, or already have a worksheet with some rows (~500) & then add another worksheet (in the background, NOT giving the new worksheet the focus) with fewer rows (~10), then the previous (and focused) worksheet will get updated scrollbar values from the (in background) added worksheet. Scrolling now will result in the error above. Hopefully this was a clear explanation ... :)
this happens when you add a new worksheet programatically and resize it manually. if you have more than 1 worksheet you can change the selected worksheet manually to avoid it. For example lets sasy i have 1 sheet on my grid and i add another one. Then i resize the second sheet manually. To avoid the problem:
gridRpt.CurrentWorksheet = gridRpt.Worksheets[1]; //set current worksheet to second sheet. (i think) this will arrange scrolls before you react with ui gridRpt.CurrentWorksheet = gridRpt.Worksheets[0]; //set current worksheet to the first sheet again
Hi out there ... I know that, as workaround I resize the focused ws by programm for 1 point, what you won't see. Your workaround is much more smart. :) But this is not the solution. My comment before yours was just to give Jing an easy way to reproduce this behavior, to find it in the source code more easily. Have a sunny day ...
Hi Jing, if you add, or already have a worksheet with some rows (~500) & then add another worksheet (in the background, NOT giving the new worksheet the focus) with fewer rows (~10), then the previous (and focused) worksheet will get updated scrollbar values from the (in background) added worksheet. Scrolling now will result in the error above. Hopefully this was a clear explanation ... :)
I can confirm this is still going on. I'm having this very same issue at the moment with multiple worksheets, and changing the CurrentWorksheet to another worksheet and back to the first one doesn't resolve it for me.
@patchcad @Gnuelmpf
hi,
I got the same error, when I add some rows to sheet1, and scoll it;
I tried gridRpt.CurrentWorksheet = gridRpt.Worksheets[1]; code, it's not work , saddly.
did you find any way to resolve this problem?
I still can't reproduce this. And in the code, there is a limitation to set the value between minimum and maximum, but why the problem happens?
if (this.scrollHorValue < this.scrollHorMin)
{
this.scrollHorValue = this.scrollHorMin;
}
else if (this.scrollHorValue > this.scrollHorMax)
{
this.scrollHorValue = this.scrollHorMax;
}
if (this.scrollVerValue < this.scrollVerMin)
{
this.scrollVerValue = this.scrollVerMin;
}
else if (this.scrollVerValue > this.scrollVerMax)
{
this.scrollVerValue = this.scrollVerMax;
}