Skip to Content
0
Former Member
Aug 21, 2008 at 02:33 PM

Null Reference when using the mouse wheel to scroll to a new page

24 Views

I'm using Crystal Reports with VS.Net 2003. Crystal reports lacks mouse wheel support when viewing reports in a crystal report viewer object. I added code to allow using the mouse wheel to scroll. I thought it would be nice to automatically scroll up to the previous page if the upper scroll limit is reached and scroll down to the next page if the lower scroll limit is reached. All that works fine, however, if a user holds down/presses the mouse wheel button as they scroll to a new page I receive the following exception:

System.NullReferenceException: Object reference not set to an instance of an object.

at CrystalDecisions.Windows.Forms.PageControl.OnMouseMove(MouseEventArgs e)

at System.Windows.Forms.Control.WmMouseMove(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I'm guessing it has to do with the fact that the mouse button press event is on one instance of the page control and when I call ShowNextPage() or ShowPreviousPage() that object becomes invalid. That's just a guess. I can't figure out how/where to trap this error, or find a solution to the problem. Any help would be greatly appreciated.