如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图?

编程入门 行业动态 更新时间:2024-10-07 14:27:19
本文介绍了如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有人,

我有一个树视图实例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.

更多推荐

如何检查树视图是否更改?保存树视图后如果有任何更改,自上次保存后如何更改树视图?

本文发布于:2023-11-12 20:49:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   有任何   如何更改

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!