首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

索引超出范围 有关问题

2013-08-04 
索引超出范围问题private void dgvInventoryAccount_CellClick(object sender, DataGridViewCellEventArgs

索引超出范围 问题

  private void dgvInventoryAccount_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int iRow = dgvInventoryAccount.CurrentCell.RowIndex;
            if (iRow >= 0)
            {
                string userID = dgvInventoryAccount.SelectedRows[iRow].Cells["UserID"].Value.ToString();
                DataSet dsTask = InventoryManager.GetInventoryTaskList(userID);
                ShowInventoryTask(dgvInventoryTask, dsTask);
            }

        }


 string userID = dgvInventoryAccount.SelectedRows[iRow].Cells["UserID"].Value.ToString();  这一行一直提示  索引超出范围。必须为非负值并小于集合大小。 请问各位大侠该怎么修改好??谢谢

[解决办法]
直接用这个:this.dataGridView1.CurrentCell.Value.ToString();

热点排行