private void btnDelete_Click(object sender, EventArgs e) { INodeViewList pNodeViewList = this.m_CurrentNode.NodeViewList; if (pNodeViewList != null) { pNodeViewList.NodeViewItems.Remove(this.m_CurrentNode); if (this.treeView1.NodeViewItems.Count == 0) { this.m_CurrentNode = null; this.SetNodeProps(null); } this.SetButtonsState(); } }
private void btnMoveUp_Click(object sender, EventArgs e) { NodeViewItem curNode = this.m_CurrentNode; NodeViewItem parent = this.m_CurrentNode.ParentNode; if (parent == null) { INodeViewList pNodeViewList = curNode.NodeViewList; if (pNodeViewList != null && pNodeViewList.NodeViewItems.Contains(curNode)) { int index = pNodeViewList.NodeViewItems.IndexOf(curNode); this.treeView1.NodeViewItems.RemoveAt(index); this.treeView1.NodeViewItems[index - 1].NodeViewItems.Add(curNode); } } else { INodeViewList pNodeViewList = curNode.NodeViewList; if (pNodeViewList != null && pNodeViewList.NodeViewItems.Contains(curNode)) { int index = pNodeViewList.NodeViewItems.IndexOf(curNode); parent.NodeViewItems.RemoveAt(index); if (index == 0) { INodeViewList pNodeViewList2 = parent.NodeViewList; if (pNodeViewList2 != null && pNodeViewList.NodeViewItems.Contains(parent)) { int index2 = pNodeViewList.NodeViewItems.IndexOf(curNode); if (parent.ParentNode == null) { this.treeView1.NodeViewItems.Insert(index2, curNode); } else { parent.ParentNode.NodeViewItems.Insert(index2, curNode); } } } else { parent.NodeViewItems[index - 1].NodeViewItems.Add(curNode); } } } this.treeView1.SelectedNode = curNode; this.m_CurrentNode = curNode; }