1.1. 查找TreeNode的根节点:findRootTreeNode

    /*
     * [Function]
     * find root TreeNode of current TreeNode
     * [Input]
     * some TreeNode
     * 
     * [Output]
     * root TreeNode of input TreeNode
     * 
     * [Note]
     */
    public TreeNode findRootTreeNode(TreeNode curTreeNode)
    {
        TreeNode rootTreeNode = curTreeNode.Parent;

        if (rootTreeNode == null)
        {
            //root parent is null
            rootTreeNode = curTreeNode;
        }
        else
        {
            //child parent is not null
            while (rootTreeNode.Parent != null)
            {
                rootTreeNode = rootTreeNode.Parent;
            }
        }

        return rootTreeNode;
    }
    

例 1.1. findRootTreeNode的使用范例

        //get input TreeNode's BrowseNode's SearchIndex
        private string getSearchIndex(TreeNode curTreeNode)
        {
            string strSearchIndex = "";

            //find the root node
            TreeNode rootTreeNode = crl.findRootTreeNode(curTreeNode);