0 out of 1 rated this helpful - Rate this topic

DataGridView.FirstDisplayedScrollingRowIndex Property

Gets or sets the index of the row that is the first row displayed on the DataGridView.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[BrowsableAttribute(false)]
public int FirstDisplayedScrollingRowIndex { get; set; }

Property Value

Type: System.Int32
The index of the row that is the first row displayed on the DataGridView.
Exception Condition
ArgumentOutOfRangeException

The specified value when setting this property is less than 0 or greater than the number of rows in the control minus 1.

InvalidOperationException

The specified value when setting this property indicates a row with a Visible property value of false.

-or-

The specified value when setting this property indicates a column with a Frozen property value of true.

Setting this property raises the Scroll event.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
ArgumentOutOfRangeException when setting this to Rows.Count-1
I have a DataGridView instance with 4 rows (1 row visible, according to DisplayedRowCount(false)), and when I set this property to 3, I get an ArgumentOutOfRangeException.  It works when I set it to 0 or 1 or 2, but not 3.  This seems to be a bug because if I set the ScrollBars property to "None", then it works fine.  I am using version 3.5 of the .NET Framework.  My stack trace:

System.Reflection.TargetInvocationException was unhandled
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.UserControl.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(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 System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at FSM.SingleInstanceApplication.Run(Form form, StartupNextInstanceEventHandler startupHandler, String[] args) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\SingleInstanceApplication.cs:line 22
       at FSM.Program.Main(String[] args) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\Program.cs:line 40
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ArgumentOutOfRangeException
       Message="Value of '66' 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.set_FirstDisplayedScrollingRowIndex(Int32 value)
            at FSM.UserControls.SensorManager.HandleNonDisconnectBenchTestResult(BenchTestChangedEventArgs e) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\UserControls\SensorManager.cs:line 593
            at FSM.UserControls.SensorManager.BenchTest_BenchTestChanged(Object sender, BenchTestChangedEventArgs e) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\UserControls\SensorManager.cs:line 430
            at FSM.BenchTests.BenchTest.RaiseBenchTestChangedEvent(BenchTestState state) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\BenchTests\BenchTest.cs:line 110
            at FSM.BenchTests.BenchTest.EndBenchTest(BenchTestState state) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\BenchTests\BenchTest.cs:line 216
            at FSM.BenchTests.BenchTest.JigCommunicator_JigCommunicatorEventHandler(Object sender, JigCommunicatorEventArgs e) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM\BenchTests\BenchTest.cs:line 158
            at FSM.DomainClasses.Threading.JigCommunicator.RaiseJigCommunicatorResultEvent(JigCommand command) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM.DomainClasses\Threading\JigCommunicator.cs:line 82
            at FSM.DomainClasses.Threading.JigCommunicator.ReceiveResult(JigCommand command) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM.DomainClasses\Threading\JigCommunicator.cs:line 204
            at FSM.DomainClasses.SensorMgr.ReceiveResult(JigCommand command) in C:\SVN\sol\nrg\trunk\software\Hybrid\FSM\FSM.DomainClasses\SensorMgr.cs:line 196
       InnerException: