Wierd exception from DataGridView, why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex21
    New Member
    • Oct 2008
    • 19

    Wierd exception from DataGridView, why?

    Ok im getting this exception from a DataGridView control in my program.

    Code:
    System.ArgumentOutOfRangeException was unhandled
      Message="Value of '132' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.\r\nParameter name: Value"
      Source="System.Windows.Forms"
      ParamName="Value"
      StackTrace:
           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)
           at System.Windows.Forms.DataGridView.ScrollRowIntoView(Int32 columnIndex, Int32 rowIndex, Boolean committed, Boolean forCurrentCellChange)
           at System.Windows.Forms.DataGridView.ScrollIntoView(Int32 columnIndex, Int32 rowIndex, Boolean forCurrentCellChange)
           at System.Windows.Forms.DataGridView.ProcessDownKeyInternal(Keys keyData, Boolean& moved)
           at System.Windows.Forms.DataGridView.ProcessDownKey(Keys keyData)
           at System.Windows.Forms.DataGridView.OnKeyDown(KeyEventArgs e)
           at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
           at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m)
           at System.Windows.Forms.Control.WmKeyChar(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.DataGridView.WndProc(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(Int32 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 Stock_Assistant.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:
    I can't scroll down to the lower rows and if i use the arrow keys to scroll down, i get this exception, why?

    Thanks for any help, Alex.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    As error messages go, this is one of the LEAST cryptic.
    Message="Value of '132' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.\r\nP arameter name: Value"
    As part of your scrolling, somewhere you are trying to assign a value to a control that is beyond its range.

    This exception should have stopped on the offending line of code. You should be able to see which control is causing it. If not... I would suggest you put a breakpoint in the scrolling method and follow it line by line (F-10). Or a few
    Code:
    console.writeline("control: " + value);
    can help a lot

    Comment

    • alex21
      New Member
      • Oct 2008
      • 19

      #3
      There is not really a method i can go through, as it is a inbuilt control, when it scrolls it just throws an exception and i don't know a way to look at its base methods.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        At some point you must be throwing a value to something.

        In Visual Studio, under the debug menu, select "exceptions " and tick on the option for raising an exception when thrown, instead of the default of 'unhandled' for the CLR

        This way as soon as the exception error occurs you can see where

        Comment

        • good spirit
          New Member
          • Jan 2012
          • 1

          #5
          try this: dgv.PerformLayo ut()

          Comment

          Working...