IfcDoc.FormEdit.SortFunction C# (CSharp) Method

SortFunction() private method

private SortFunction ( ) : void
return void
        private void SortFunction()
        {
            TreeNode tn = this.treeView.SelectedNode;
            DocFunction docEntity = (DocFunction)tn.Tag;

            DocSchema docSchema = (DocSchema)this.treeView.SelectedNode.Parent.Parent.Tag;
            int indexOld = docSchema.Functions.IndexOf(docEntity);
            docSchema.SortFunctions();
            int indexNew = docSchema.Functions.IndexOf(docEntity);
            if (indexNew != indexOld)
            {
                TreeNode tnParent = tn.Parent;
                tn.Remove();
                tnParent.Nodes.Insert(indexNew, tn);
                this.treeView.SelectedNode = tn;
            }
        }
FormEdit