今天遇到一个问题,就是单击Gridview中单元格的checkbox的值,代码如下所示:
DataGridViewCell Cell = dataGridViewXUser.Rows[e.RowIndex].Cells[e.ColumnIndex];
string Str_UserName = dataGridViewXUser.Rows[e.RowIndex].Cells[0].Value.ToString().Trim(); //获取账户类型
bool editValue = Convert.ToBoolean(Cell.EditedFormattedValue);
if (editValue == true)
{
//将该账号授权
if (FunctionUserAuthorize(Str_UserName,true)==true)
{
MessageBox.Show(Str_UserName+"授权成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
}
else
{
//取消该账户的授权
if (FunctionUserAuthorize(Str_UserName, false) == true)
{
MessageBox.Show(Str_UserName + "成功取消授权!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
}