public void SelectNode(TreeNode node) { TaskControlContainer tcc = (TaskControlContainer)node.Tag;//TaskControl tc = (TaskControl)e.Node.Tag; if (PrevTC != null) { try { PrevTC.Close(); } catch (Exception ex) { Common.Log(ex); } } PrevTC = tcc.Contr; UserControl uc = (UserControl)PrevTC;//(UserControl)e.Node.Tag; while (TaskPanel.Controls.Count > 0) { Control c = TaskPanel.Controls[0]; TaskPanel.Controls.RemoveAt(0); //c.Dispose(); } uc.Dock = DockStyle.Fill; TaskPanel.Controls.Add(uc); //TaskPanel.Enabled = true;// (PrevTC.NeedEnter() == false); PrevTC.Select(node, true);//tc.Select(e.Node, false); CheckTitle(); }