private void sfListView1_SelectionChanged(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangedEventArgs e) { if (e.AddedItems.First().GetType().Name == nameof(GroupResult)) { return; } var actionInfo = this.actionsDataSource.Find(x => x.Action == ((ActionInfo)e.AddedItems.First()).Action) ?? new ActionInfo() { Action = { } }; var records = gridGroupingControl1.Table.SelectedRecords; List <Task> selectedTasks = new List <Task>(); foreach (var record in records) { selectedTasks.Add(service.ts.AllTasks.First(t => t.Name.Equals(record.Record.GetValue(nameof(t.Name))))); } List <Task> tasks = new List <Task>(); try { tasks = actionInfo.Action(selectedTasks); } catch (UnauthorizedAccessException) { var identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); MessageBox.Show($"Cannot delete task with your current identity '{identity.Name}' permissions level." + "You likely need to run this application 'as administrator' even if you are using an administrator account.", "Attention"); } if (actionInfo.Action == Service.CreateTask) { tasks.ForEach(t => tasksDataSource.Add(new TaskData(t))); gridGroupingControl1.DataSource = tasksDataSource; } if (actionInfo.Action == service.DeleteTasks) { tasks.ForEach(t => tasksDataSource.Remove(tasksDataSource.First(x => x.item.Name.Equals(t.Name)))); gridGroupingControl1.DataSource = tasksDataSource; } if (actionInfo.Action == Service.EditTask || actionInfo.Action == Service.SwitchStateTasks) { RefreshGridView(); } var listView = (SfListView)sender; listView.SelectedIndex = -1; }
private void DropDownListView_SelectionChanged(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangedEventArgs e) { if (e.AddedItems.Count == this.sfComboBox.DropDownListView.View.Items.Count) { for (int i = 0; i < this.sfComboBox.DropDownListView.CheckedItems.Count; i++) { if ((this.sfComboBox.DropDownListView.CheckedItems[i] as Details).IsEnabled == false) { this.sfComboBox.DropDownListView.CheckedItems.RemoveAt(i); } } } }