如何按排序顺序插入树项? [英] How do I insert tree items in a sorted order?

查看:86
本文介绍了如何按排序顺序插入树项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的treectrl类,我想在树中插入一些项目,是否有任何可能的方法以排序顺序插入项目(最后创建的文件应首先显示)。基本上我创建的treectrl用作listctrl,所以每个项目自动成为父项,没有父项有子项。

我不能使用SortChildren()因为没有项目作为子项插入。



我尝试了什么:



我试图获得文件创建时间,并排序它的基础,但我得到文件创建时间后无法排序。

I have a custom treectrl class and i want insert some items into tree,is there any possible way to insert items in a sorted order(last created file should display first). Basicaly the treectrl which i have created is used as listctrl so each item is automatically become parent and no parent has children.
I can not use SortChildren() beacause no items are inserted as child.

What I have tried:

I tried to get filecreation time,and sort basis of it,but i can't sort after getting file creation time.

推荐答案

为此你必须清楚地分开视觉显示(视图)和数据源(模型)。

您的数据听起来不仅仅是有序列表或数组。插入订购的数据,然后重新加载数据。



列表控件有很多可能性,所以看一下articel 使用列表控件。它具有激活排序或设置排序功能的选项(用于回调排序)。
For that you must cleary separate the visual display (View) and the data source (Model).
Your data sounds more than a ordered list or an array. Insert the data ordered and than reload the data.

The list control has a lot of possibilities, so take a look at the articel Using the List Control. It has option for adeactivating ordering or setting a sort function (for callback ordering).


这篇关于如何按排序顺序插入树项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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