private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { var aNode = (MorphNode)e.Node; switch (aNode.NodeType) { case clNodeType.clnContainer: { // Обновление детей и документов в дереве store.RefreshContainer(aNode.bdID); var container = store.GetContainerByID(aNode.bdID); PopulateTreeChildrenConts(container, aNode); PopulateTreeDocuments(container, aNode); var chldrn = container.Children(); foreach (var chldCont in chldrn) { var chNode = FindNode(chldCont.ContainerID, aNode); //if (chNode == null) PopulateTreeChildrenConts(chldCont, chNode); PopulateTreeDocuments(chldCont, chNode); } break; } case clNodeType.clnDocument: { // Обновление заголовков абзацев в дереве var contID = (aNode.Parent as MorphNode).bdID; var docID = aNode.bdID; var dMap = store.RefreshParagraphs(contID, docID); var parags = dMap.GetParagraphs(); foreach (MorphNode node in aNode.Nodes) { var paragraph = parags.Where(x => x.ParagraphID == node.bdID).FirstOrDefault(); node.Text = paragraph.GetHeader(); } break; } } }