Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在更新面板中使用 Treeview。在加载树视图时,我只想扩展节点 3 个级别,即深度 = 3。我使用了 Expand Depth 属性并设置了“ExpandDepth=3”。但是扩展不起作用。感谢你的帮助。
我用下面的代码修复了它。
私人无效ExpandAll(){
foreach (TreeNode i in TreeView1.Nodes) { i.Expand(); foreach (TreeNode f in i.ChildNodes) { f.Expand(); foreach (TreeNode g in f.ChildNodes) { if(g.Depth==0) { g.Expand(); } } } } }