The C-sharp treeview control gets the child

treeview control in C-sharp winform
how to get leaves after 3 layers of selected items in treeview

Jun.20,2021

first get treeNode of Wang Sicong, then visit treeNode.Nodes recursive traversal, enter the next layer + 1, start at 3, and then traverse all the nodes you want.
Click


solved, return the leaf text after three layers.

 private List<string> GetChildList(TreeNode node, int level)
        {
            List<string> result = new List<string>(); ;

            //MessageBox.Show(level.ToString()+" " + node.Text);

            levelPP;

            if (node.Nodes.Count > 0)
            {
                foreach (TreeNode nod in node.Nodes)
                {
                    if (level > 3)
                    {
                        result.Add(nod.Text);
                    }

                    List<string> li = GetChildList(nod, level);

                    if (li.Count > 0)
                    {
                        foreach (string line in li)
                        {
                            result.Add(line);
                        }
                    }
                }
            }

            return result;
        }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d8a7-2c3ad.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d8a7-2c3ad.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?