我有一个代码如下:系统参数超出范围的异常,同时增加行datagridview的
private void svars_MouseDoubleClick(object sender, MouseEventArgs e)
{
userSelection user_sel = new userSelection();
string file = svars.SelectedItem.ToString();
DataGridViewRow row = new DataGridViewRow();
dataGridView1.Rows.Add(row);
row.Cells["Local_Variables"].Value = "test";
DataGridViewCell sysvar = new DataGridViewTextBoxCell();
sysvar.Value = file;
row.Cells["System_Variables"] = sysvar;
}
我收到错误以下错误:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: Specified argument was out of the range of valid values.
当我试图调试我发现row.Index是-1。我不知道如何解决它。任何人都可以请帮忙。
谢谢。
什么是堆栈跟踪? – SLaks 2012-03-25 23:09:39
我不确定如何查看,但只要程序读取此行即可.Cells [“Local_Variables”]。Value =“test”;它给出了错误。 – 2012-03-25 23:14:49
查看详细信息... – SLaks 2012-03-25 23:15:12