索引超出范围 有关问题

索引超出范围问题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();