请教各位前辈:
以下是一段错误记录,请问我怎么才知道问题出在哪.如果这些信息不足以找出问题点的话,我还需要记录哪些信息?谢谢!电脑名称:E*****
用户名称:R*****\u***
IP地址:192.168.1.*
物理内存:519553024
发生时间2009-1-6 16:34:23:
错误信息:指定的参数已超出有效值的范围。
参数名: rowIndex
类名:DataGridView
方法名:GetCellDisplayRectangle
StackTrace:   在 System.Windows.Forms.DataGridView.GetCellDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
   在 System.Windows.Forms.DataGridView.GetCellAdjustedDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
   在 System.Windows.Forms.DataGridView.InvalidateCellPrivate(Int32 columnIndex, Int32 rowIndex)
   在 System.Windows.Forms.DataGridView.OnCellCommonChange(Int32 columnIndex, Int32 rowIndex)
   在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
   在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
   在 System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
   在 System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
   在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.CancelRowEdit(Boolean restoreRow, Boolean addNewFinished)
   在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowValidating(DataGridViewCellCancelEventArgs e)
   在 System.Windows.Forms.DataGridView.OnRowValidating(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex)
   在 System.Windows.Forms.DataGridView.OnValidating(CancelEventArgs e)
   在 System.Windows.Forms.Control.PerformControlValidation(Boolean bulkValidation)
   在 System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control ancestorControl, Boolean preventFocusChangeOnError)
   在 System.Windows.Forms.ContainerControl.ValidateInternal(Boolean checkAutoValidate, Boolean& validatedControlAllowsFocusChange)
   在 System.Windows.Forms.ContainerControl.ValidateInternal(Boolean checkAutoValidate, Boolean& validatedControlAllowsFocusChange)
   在 System.Windows.Forms.ContainerControl.Validate(Boolean checkAutoValidate)
   在 System.Windows.Forms.Form.WmClose(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

解决方案 »

  1.   

    你要记录是运行了哪行代码哪个方法,接受的变量是什么.等出错的信息.exception会提供给你的. 
      

  2.   

    ArgumentOutOfRangeException columnIndex is less than -1 or greater than the number of columns in the control minus 1. 
    -or- 
    rowIndex is less than -1 or greater than the number of rows in the control minus 1. 
     
    分析一下,代码里调用的行或者列越界了
      

  3.   

    ArgumentOutOfRangeException columnIndex is less than -1 or greater than the number of columns in the control minus 1. 
    -or- 
    rowIndex is less than -1 or greater than the number of rows in the control minus 1. 分析一下,代码里调用的行或者列越界了
      

  4.   

    看了一下 你这个错误是在窗口关闭的时候发生的
    窗口关闭的时候,DataGridView关闭或者析构的时候发生错误,具体类型是参数错误
    你看一下有没有InternalException估计是你的DataGridView有问题,比如在还没有完全打开的时候就关闭....或者正在进行某些操作啊,后者某些东西没有初始化完成...等等 都有可能
      

  5.   

    错误信息:指定的参数已超出有效值的范围。
    参数名: rowIndex 看堆栈似乎是修改某行的时候关闭窗口出错,找找代码中操作DataGridView的地方
      

  6.   

    具体的你要生成 的可执行文件时不要用Release模式 要用Debug模式,这样在生成 Exe文件时会生成相应的PDB文件,这样如果你的程序报错的话,会在Exception里会显示引起报错的具体哪个文件名与在这个文件里具体哪一行数这样你就可以找到原因了,不过你还得需要Try{}Catch{}里去写日志,其他 的还是没有什么好的方法了,呵
      

  7.   

    PDB文件 就是包括调试信息的,所以就得显示出具体哪一行代码引起报错了
      

  8.   

    这个错误是微软的bug参看:
    http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/ec08d0b4-5779-49b3-ae8a-40d064e79374/
      

  9.   

    怀疑 DataGridView 内部有个状态维护出了问题,,
      

  10.   

    那如何利用PDB文件呢.没听懂.谢谢!
      

  11.   

    错误信息:指定的参数已超出有效值的范围。 
    参数名: rowIndex 
    类名:DataGridView 
    方法名:GetCellDisplayRectangle 
    写的很清楚.
      

  12.   

    但类名是DataGridView 我不可能去改它的代码吧.我的意思是如何找出真正产生此问题的原因然后解决这个问题.谢谢!
      

  13.   

    那个帖子的代码我简化了一下:
    多次点击, 行来回切换, 就报那个错误, 错误堆栈跟你的, 那个帖子的完全一样
    分析一下这段看, 窗体放置 DataGridView 默认属性
      public partial class Form1 : Form
      {
        DataTable dt = null;
        public Form1()
        {
          InitializeComponent();
        }    protected override void OnLoad(EventArgs e)
        {
          base.OnLoad(e);
          CreateTable();
          dataGridView1.DataSource = dt;
          dataGridView1.CellLeave+=new DataGridViewCellEventHandler(dataGridView1_CellLeave);
        }    void CreateTable()
        {
          dt = new DataTable();
          dt.Columns.Add("a");
          dt.Columns.Add("b");
          dt.Columns.Add("c");
          dt.Columns.Add("d");
        }    void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
          if (this.dataGridView1.Columns[e.ColumnIndex].Name.ToUpper() == "b".ToUpper())
          {
            dataGridView1[e.ColumnIndex, e.RowIndex].Value += "c";
          }
        }
      

  14.   

    我也遇到問題了
    System.InvalidOperationException: Operation is not valid due to the current state of the object.
    也是來回點擊時報的錯
      

  15.   

    我也碰到同样的问题了,这个错误是微软的bug吗?
    如果是的话,该怎么解决呢?
    打.NET补丁吗?