private void DepartmentsTree_SelectionChanged(object sender, EventArgs _) { TreeNode node = DepartmentsTree.SelectedNode; Employee[] emps = ((node != null ? (Employee[])Tree.GetTreeNodeData(node) : null) ?? new Employee[0]); EmployeesGrid.BeginRebuild(); foreach (Employee e in emps) { EmployeesGrid.AddItem(GetGridTexts(e), e); } EmployeesGrid.AddItem(GetGridTexts(null), null); EmployeesGrid.EndRebuild(); }