/// <summary> /// Run asynchroniously to not stop XrmToolBox. /// </summary> private void OnIndexChanged(CheckedListBox listBox) { // Prevent from further clicking this.SetAllEnable(false); // Uncheck everything listBox.ClearAllSelections(); // Set as checked only checked item listBox.SetItemCheckState(listBox.SelectedIndex, CheckState.Checked); // Checked User var userIndex = listBox.SelectedIndex; // Checked Model connected with User CurrentSelectedUser = this.Users.ElementAt(userIndex); // Calculate permissions for selected User CalculatePermissions(); // After everything enable - enable Roles for future plans this.SetAllEnable(true); }