DataGridView scroll error - minimum and maximum values
-
Wednesday, July 22, 2009 3:18 PM
I have added a datagridview to my form. The scrollbar property is set to Vertical. If I add say 21 rows to the grid, and then try to use the down arrow key the following error is generated :-
/EnvironmentVariables>
<Exception Type="ArgumentOutOfRangeException">
<Message>Value of '176' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value</Message>
<Source>System.Windows.Forms</Source>
<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.ProcessDataGridViewKey(KeyEventArgs e)
at System.Windows.Forms.DataGridView.ProcessKeyPreview(Message& m)
at System.Windows.Forms.Control.ProcessKeyPreview(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</StackTrace>
<HelpLink />
<TargetSite>set_Value</TargetSite>
</Exception>
Using the scroll bar, does not display all rows that have been added to the datagrid.- Moved by Zhi-Xin Ye Tuesday, July 28, 2009 2:09 PM (From:.NET Base Class Library)
All Replies
-
Wednesday, July 22, 2009 6:47 PM
Hello,
<Message>Value of '176' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value</Message>
What I get from this message is that, the datasource row count is smaller than 176. That's why vertical scroll does not work for that.
However, if you send the code where this exception thrown, it can be more clear. From this point, detailed explanation can not be given, I guess. You may send some psudo or code itself on scrol method.- Proposed As Answer by Jones Huang Thursday, April 07, 2011 8:36 AM
-
Friday, July 31, 2009 8:02 AM
Thanks, but if I included PerfomLayout it solved my problem.- Proposed As Answer by Madhavan L Wednesday, August 12, 2009 7:39 AM
-
Wednesday, August 12, 2009 7:39 AMHi, I also get the same error in my application. Where you included PerformLayout(). Kindly help me out
Madhavan -
Sunday, July 11, 2010 7:08 AM
hi
you shoud add it after code adds Rows to your Datagridview
like this
for (int x = 0; x <20 ; x++)
datagrid.Rows.Add((x).ToString(), "-----");
datagrid.PerformLayout();- Proposed As Answer by Alan Cossari Thursday, December 16, 2010 1:01 PM
-
Sunday, December 26, 2010 4:36 AMMany thank your answer
-
Thursday, March 17, 2011 6:56 AMI's Great Thank you so much
-
Thursday, April 07, 2011 8:37 AM
hi
you shoud add it after code adds Rows to your Datagridview
like this
for (int x = 0; x <20 ; x++)
datagrid.Rows.Add((x).ToString(), "-----");
datagrid.PerformLayout();
Thanks very much!!- Proposed As Answer by pthsoon Wednesday, November 02, 2011 7:55 AM
-
Wednesday, July 27, 2011 5:23 PMExcelente, muchísimas gracias!