请教大家一个问题,我们项目作了个系统,在平时运行的时候都很正常,什么问题都没有,但是在显示datagrid数据的时候,如果鼠标在datagrid上面随便点击,滚动datagrid滚动条的时候(可能在某种特定的情况下),有时候我鼠标在项目上点了10几分钟才会出现这种情况,有时候点个2-3分钟才会出现这种情况,不过不随便乱点,就不会出现下面的bug,但是用户反应有这种问题,我测了一上午,点了一上午终于也发现这个问题了,搞的为了调试每句代码都跟进,但是每次系统报错都直接跳转到  
Application.SetCompatibleTextRenderingDefault(false);
                    Program.log.Error("跟踪系统启动记录:Application设置3");                    frmM = new frmDefault();
                    Application.Run(frmM);  --系统第一次登录的时候显示的窗体,但是在我报错的时候就是显示这句话错误。我跟进的代码是我报错的页面。这句话前后我也都设置了断点,但都没有作用直接调到这一句,前后都不执行。各位高手帮忙分析下。2009-12-15 17:12:43,140 [9] ERROR PlanBook.Program [(null)] <(null)> - System.ArgumentOutOfRangeException: “-41”的值对于“Value”无效。“Value”应介于 'minimum' 和 'maximum' 之间。
参数名: Value
   在 System.Windows.Forms.ScrollBar.set_Value(Int32 value)
   在 System.Windows.Forms.DataGridView.ScrollRows(Int32 rowCount, Int32 deltaY, ScrollEventType scrollEventType)
   在 System.Windows.Forms.DataGridView.ScrollRowsByCount(Int32 rows, ScrollEventType scrollEventType)
   在 System.Windows.Forms.DataGridView.OnMouseWheel(MouseEventArgs e)
   在 System.Windows.Forms.Control.WmMouseWheel(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.DataGridView.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.Run(Form mainForm)
   在 PlanBook.Program.Main() 位置 D:\Project\PlanBook\FORM\PlanBook\Program.cs:行号 159

解决方案 »

  1.   

    ScrollBar 的有效值应该是 0 - 100 之间吧
      

  2.   

    ScrollBar的值应该在你设置的minvalue和maxvalue之间的,你在运行的时候发稿ScrollBar的value的时候判断一下的
      

  3.   

    -41 是你的ScrollBar的合法取值吗?
      

  4.   

    哪个地方的值不在范围内。估计在frmDefault的load里,你在frmDefault的load里设置断点跟踪一下。
      

  5.   

     怎么判断,在哪里判断,我在我报错的那个datagrid页面全程跟进了,每个函数都设置了断点,但是报错的时候直接跳到Application.Run(frmM); 这句话前后都么有执行。直接报错。
      

  6.   

     这个value是最是变动的,有时候是-41,有时候是-10,有时候-。。,这个值好像随便变动,不过变来变去基本上都是负数。
      

  7.   

    这个value是最是变动的,有时候是-41,有时候是-10,有时候-。。,这个值好像随便变动,不过变来变去基本上都是负数。
      

  8.   

     将表格的属性设置成:UpdateRowHeightInfo(0, True)应该就可以了