diff --git a/WinFormSolution/Components/UserControlTreeView.cs b/WinFormSolution/Components/UserControlTreeView.cs index 52a3623..2b94e06 100644 --- a/WinFormSolution/Components/UserControlTreeView.cs +++ b/WinFormSolution/Components/UserControlTreeView.cs @@ -35,7 +35,7 @@ namespace Components throw new NotSelectedNodeException(); } - if ((Hierarchy?.Count ?? 0) > 0) + if ((Hierarchy?.Count ?? 0) == 0) { throw new TreeHierarchyNotSetException(); } @@ -83,7 +83,7 @@ namespace Components return; } - if ((Hierarchy?.Count ?? 0) > 0) + if ((Hierarchy?.Count ?? 0) == 0) { throw new TreeHierarchyNotSetException(); } diff --git a/WinFormSolution/WinFormsApp/Form.cs b/WinFormSolution/WinFormsApp/Form.cs index 0cfa343..839d869 100644 --- a/WinFormSolution/WinFormsApp/Form.cs +++ b/WinFormSolution/WinFormsApp/Form.cs @@ -45,12 +45,13 @@ namespace WinFormsApp employees.Add(new Employee("Отдел финансов", "Аналитик", "Астафьев", "Павел")); employees.Add(new Employee("Отдел закупок", "Аналитик", "Смирнова", "Анастасия")); - List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy = new(); - - hierarchy.Add(("Departament", false)); - hierarchy.Add(("Position", false)); - hierarchy.Add(("Surname", false)); - hierarchy.Add(("Name", false)); + List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy = + [ + ("Departament", false), + ("Position", false), + ("Surname", false), + ("Name", false), + ]; userControlTreeView.SetHierarchy(hierarchy);