Добавил проверки на наличие иерархии

This commit is contained in:
Никита Потапов 2024-09-23 14:43:10 +04:00
parent 472cd6d16f
commit 8e34e6aca4
2 changed files with 9 additions and 8 deletions

View File

@ -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();
}

View File

@ -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);