private void grdUser_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (IsANonHeaderButtonCell(e)) { string userId = BaseInterfaceLogic.GetDataGridViewEntityId(this.grdUser, BaseUserEntity.FieldId); if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(this.TargetPermissionId)) { FrmUserPermissionScope frmUserPermissionScope = new FrmUserPermissionScope(userId, this.PermissionItemScopeCode); frmUserPermissionScope.ShowDialog(this); } } // 保证只能勾选一个 else if (this.grdUser.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewCheckBoxCell) { Boolean bl = Convert.ToBoolean(this.grdUser.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue); if (bl) { this.grdUser.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = bl; dtUserOrganizeScope.Rows[e.RowIndex]["colDetail"] = false; //勾选其他选项后Detail项为false for (int i = 0; i < e.ColumnIndex; i++) { if (this.grdUser.Rows[e.RowIndex].Cells[i] is DataGridViewCheckBoxCell) { this.grdUser.Rows[e.RowIndex].Cells[i].Value = !bl; } } for (int i = e.ColumnIndex + 1; i < grdUser.ColumnCount; i++) { if (this.grdUser.Rows[e.RowIndex].Cells[i] is DataGridViewCheckBoxCell) { this.grdUser.Rows[e.RowIndex].Cells[i].Value = !bl; } } } } }