排序树视图时自动添加节点 [英] Sort TreeView Automatically Upon Adding Nodes

查看:124
本文介绍了排序树视图时自动添加节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法将节点添加到一个WinForms .NET TreeView控件,其中所添加的新节点插入正确的索引,以便整个节点列表是按字母顺序排序? pretty的许多具有相同的结果TreeView.Sort()。

Is there an easy way to add nodes to a WinForms .NET TreeView control where the new nodes being added are inserted at the correct index so the entire list of nodes is sorted alphabetically? Pretty much having the same result as TreeView.Sort().

我有一个TreeView,不断成长为几百节点。用户可以实时查看此TreeView控件因为它的增长。我想preFER刚刚插入节点正确的索引,而不是调用TreeView.Sort()一个节点添加后各一次。

I have a TreeView that continually grows to a couple hundred nodes. The user can view this TreeView in real time as it grows. I'd prefer to just insert the nodes at the correct index, rather than calling TreeView.Sort() each time after a node is added.

可以这样做?

推荐答案

在的WinForms,你可以简单地设置TreeView的 .Sorted 属性

In winforms, you can simply set the TreeView's .Sorted property to True.

当排序设置为true,   TreeNode对象进行排序   按字母顺序排列的文字   属性值。你应该总是使用   的BeginUpdate和EndUpdate维持   加入了大量的性能时,   项的数量的排序   树视图。当现有的文本   节点改变,你必须调用排序,以   度假村的项目。

When Sorted is set to true, the TreeNode objects are sorted in alphabetical order by their Text property values. You should always use BeginUpdate and EndUpdate to maintain performance when adding a large quantity of items to a sorted TreeView. When the text of an existing node is changed, you must call Sort to resort the items.

参考<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.sorted.aspx">MSDN

这篇关于排序树视图时自动添加节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆