如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图? [英] How to check if a treeview is changed or not? If there is any change after the treeview is saved, how to know the treeview is changed since last saved?

查看:138
本文介绍了如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我有一个树视图实例treeView1,用户可以在我的应用程序中从此treeView1添加节点到/ remove节点。应用程序提供保存功能以将treeView1保存到硬盘驱动器。

I have a treeview instance treeView1, and user can add node to / remove node from this treeView1 on my application. Application provides save function to save treeView1 to hard drive.

如果用户将当前的treeView1保存到硬盘驱动程序,并在treeView1上执行其他操作,例如编辑节点文本,添加节点或删除节点,...

If users save the current treeView1 to hard driver, and do other operation on treeView1, e.g. editing node text, add node, or remove node,...

如何检查树视图是否已更改?

How to check if a treeview is changed or not?

我想做的是,如果自上次保存以来treeView1上没有任何更改,并且用户想要退出应用程序,应用程序退出而不提示;另一方面,如果treeView1上有任何更改,应用程序会提示"treeView1已更改,
是否要在退出前保存treeView1?"

I would like to do is if there is no any change on treeView1 since last saved, and users want to exit application, application exit without prompt; on the other hand, if there is any change on treeView1, application prompts "The treeView1 is changed, do you want to save treeView1 before exiting?"

谢谢和问候,

E-John

推荐答案

真的不是清除你在这里要求的东西,因为树视图不是动态对象。其中的节点必须以编程方式放置在那里。添加/更改节点的代码将是您执行任何"保存"操作的位置。逻辑。当节点发生变化时,您可以将
挂钩到树视图的相应事件中,但这样做会很昂贵,因为您必须在树级别处理节点更改,并且可能还需要处理单个节点(即节点文本已更改)。 

Really not clear what you're asking for here because a treeview is not a dynamic object. The nodes within it have to be programmatically placed there. The code that adds/changes the nodes would be where you'd do any "save" logic. You could hook into the appropriate events for the treeview when nodes changed but that would be expensive since you'd have to handle node changes at the tree level and possibly individual nodes as well (i.e. node text changed). 

我会在你更新树时处理保存。 UI不应该是数据源。数据源在树中表示。当数据源发生变化时,您可以进行保存,然后更新UI。不是相反。

I would handle saving when you update your tree. The UI shouldn't be the source of data. The source of data is represented in the tree. When the source of data changes you do your save and then you update your UI. Not the other way around.


这篇关于如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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