コード例 #1
0
        /// <summary>
        /// unindent the selected node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _unindentButton_Click(object sender, EventArgs e)
        {
            TreeNode node  = this._treeView.SelectedNode;
            MenuItem oItem = (MenuItem)_treeView.SelectedNode.Tag;

            if (node != null)
            {
                TreeNode node2  = node.Parent;
                MenuItem oItem2 = oItem.Parent;
                if (node2 != null)
                {
                    TreeNodeCollection collection1     = this._treeView.Nodes;
                    MenuItemCollection oItemCollection = _navBar.Items;
                    if (node2.Parent != null)
                    {
                        collection1     = node2.Parent.Nodes;
                        oItemCollection = oItem2.Parent.ChildItems;
                    }
                    if (node2 != null)
                    {
                        node.Remove();
                        RemoveMenuItem(oItem);
                        collection1.Insert(node2.Index + 1, node);
                        oItemCollection.AddAt(oItemCollection.IndexOf(oItem2) + 1, oItem);
                        this._treeView.SelectedNode = node;
                    }
                }
            }
        }