DataGridView滚动错误 - 最小值和最大值 [英] DataGridView scroll error - minimum and maximum values

查看:156
本文介绍了DataGridView滚动错误 - 最小值和最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在表单中添加了一个datagridview。滚动条属性设置为"垂直"。如果我向网格添加21行,然后尝试使用向下箭头键,则会生成以下错误: -

/ EnvironmentVariables>
< Exception Type =" ArgumentOutOfRangeException" >
< Message>'176'的值对'Value'无效。 "值"应介于"最小"和"最大"之间。
参数名称:值< /消息>
< Source> System.Windows.Forms< / Source>
< StackTrace> ;在System.Windows.Forms.ScrollBar.set_Value(Int32值)
在System.Windows.Forms.DataGridView.ScrollRows(Int32 rowCount,Int32 deltaY,ScrollEventType scrollEventType)
在System.Windows.Forms.DataGridView .ScrollRowsByCount(Int32 rows,ScrollEventType scrollEventType)
在System.Windows.Forms.DataGridView.ScrollRowIntoView(Int32 columnIndex,Int32 rowIndex,Boolean committed,Boolean forCurrentCellChange)
在System.Windows.Forms.DataGridView.ScrollIntoView (Int32 columnIndex,Int32 rowIndex,Boolean forCurrentCellChange)
在System.Windows.Forms.DataGridView.ProcessDownKeyInternal(Keys keyData,Boolean& amp; moved)
在System.Windows.Forms.DataGridView.ProcessDownKey(Keys) keyData)
在System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)的System.Windows.Forms.DataGridView.ProcessKeyPreview(Message& amp; m)
在System.Windows上。 Forms.Control.ProcessKeyPreview(Message& amp; m)
a t System.Windows.Forms.Control.ProcessKeyMessage(Message& amp; amp; m)在System.Windows.Forms.Control.WmKeyChar(Message& amp; m)
在System.Windows.Forms.Control.WndProc(Message& amp; m)
在系统中.Windows.Forms.TextBoxBase.WndProc(Message& amp; m)
在System.Windows.Forms.TextBox.WndProc(Message& amp; m)
在System.Windows.Forms.Control.ControlNativeWindow .OnMessage(Message& amp; m)
在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& amp; m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,IntPtr wparam,IntPtr lparam)< / StackTrace>
< HelpLink />
< TargetSite> set_Value< / TargetSite>
< / Exception>

使用滚动条,不显示已添加到数据网格的所有行。


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&amp; moved)
   at System.Windows.Forms.DataGridView.ProcessDownKey(Keys keyData)
   at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)
   at System.Windows.Forms.DataGridView.ProcessKeyPreview(Message&amp; m)
   at System.Windows.Forms.Control.ProcessKeyPreview(Message&amp; m)
   at System.Windows.Forms.Control.ProcessKeyMessage(Message&amp; m)
   at System.Windows.Forms.Control.WmKeyChar(Message&amp; m)
   at System.Windows.Forms.Control.WndProc(Message&amp; m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message&amp; m)
   at System.Windows.Forms.TextBox.WndProc(Message&amp; m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; 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.

推荐答案


你好,

<消息>'176'的值对'Value'无效。 "值"应介于"最小"和"最大"之间。
参数名称:值< /消息>

从此消息中得到的是,数据源行数小于这就是为什么垂直滚动不起作用的原因。
但是,如果发送抛出此异常的代码,则可以更清楚。从这一点来说,我猜是不能给出详细的解释。您可以在scrol方法上发送一些psudo或代码本身。

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.


这篇关于DataGridView滚动错误 - 最小值和最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆