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 节点并根据特定值检索节点的最佳方法是什么?
创建类似 a 的东西Dictionary<string, TreeNode>并在其中添加所有节点会更有效。这当然必须在表单开始时或添加新树节点时完成。字典键可以是任何东西,例如 TreeNode 文本或与节点关联的业务对象。
Dictionary<string, TreeNode>
您不需要遍历所有节点 - 只需使用搜索条件(键)并检索节点。