delphi help:
Determines if and how the nodes in a tree view are automatically sorted.type TSortType = (stNone, stData, stText, stBoth);
property SortType: TSortType;DescriptionOnce a tree view is sorted, the original hierarchy is lost. That is, setting the SortType back to stNone will not restore the original order of items. These are the possible values:Value MeaningstNone No sorting is done.
stData The items are sorted when the Data object or SortType is changed.
stText The items are sorted when the Caption or SortType is changed.
stBoth The items are sorted when either the Data object, the Caption or SortType is changed Optionally, the OnCompare event can be hooked to handle comparisons. The OnCompare event will be called to compare two nodes for sorting.
Determines if and how the nodes in a tree view are automatically sorted.type TSortType = (stNone, stData, stText, stBoth);
property SortType: TSortType;DescriptionOnce a tree view is sorted, the original hierarchy is lost. That is, setting the SortType back to stNone will not restore the original order of items. These are the possible values:Value MeaningstNone No sorting is done.
stData The items are sorted when the Data object or SortType is changed.
stText The items are sorted when the Caption or SortType is changed.
stBoth The items are sorted when either the Data object, the Caption or SortType is changed Optionally, the OnCompare event can be hooked to handle comparisons. The OnCompare event will be called to compare two nodes for sorting.
在node下添加一个子节点。如果加一个根节点
GroupTree.Items.AddChild(nil,'SuperNode');即可
这个加入是后插入,就是加在所有子节点后面
AddChildFirst可以实现前加入。
你添加时除非用了什么操作,否则
添加时就是按照上面的规则来加入(可以控制前加入还是后面后面加入)。
例如
1
11
111
112
12
121
2
21
211
22
ABC
DEF
这个树,你现在加入节点hh到22下,你可以控制加入ABC前面或者def后面,不能直接插入中间(需要移动节点来实现)。
如果用
22.addchild('hh')就变成 22
ABC
DEF
hh
如果22.addChildFirst('hh');
变成
22
hh
ABC
DEF
,你说的不是这个意思吗?你给个图示说明吧?
显示的时候是
1
10
2
因为他进行了排序,认为10是在2的前面,如果在1和2的前面加上空格,顺序就是 1、 2、10,因为空格比1的ascii要小,所以空格+2就排在了10的前面了。
我现在不需要他来给我排序,我要他按我添加的顺序显示,即
1
2
10
sorttype是stnone但却按照ascii在排列!
sorttype能不能在运行期实现?
node:=treeview1.selected;
treeview1.Items.Insert(node,edit1.text);
添加子节点也一样。
node:=treeview1.selected;
treeview1.Items.AddChild(node,edit1.text);
1--
11
33
加22
就是
1--
11
33
22
我想自动生成
1--
11
22
33
我想过用text属性,不过太麻烦,我还没调通,大家给点建议哈
把NODE给记录类型
再取出来,记录类型里面有数据库的值