Ejemplo n.º 1
0
        protected virtual void SearchNodeClick(object sender, EventArgs e)
        {
            if (this.searchBox.Text.Length > 0)
            {
                TreeViewerNode node = null;
                foreach (TreeNode n in this.Tree.Nodes)
                {
                    if (n is TreeViewerNode)
                    {
                        node = (n as TreeViewerNode).SearchNode(this.searchBox.Text);
                    }
                    if (node != null)
                    {
                        break;
                    }
                }

                if (node != null)
                {
                    if (this.Tree.SelectedNode != node)
                    {
                        this.Tree.SelectedNode      = node;
                        this.SearchButton.BackColor = System.Drawing.Color.Green;
                    }
                }
                else
                {
                    this.Tree.SelectedNode      = null;
                    this.SearchButton.BackColor = System.Drawing.Color.Red;
                }
            }
        }
Ejemplo n.º 2
0
        public TreeViewerNode SearchNode(string name)
        {
            if (this.Text.Contains(name))
            {
                return(this);
            }

            foreach (TreeNode node in this.Nodes)
            {
                if (node is TreeViewerNode)
                {
                    TreeViewerNode childNode = (node as TreeViewerNode).SearchNode(name);
                    if (childNode != null)
                    {
                        return(childNode);
                    }
                }
            }
            return(null);
        }