简体   繁体   English

在WinForms .NET C#中,如何将TreeView控件的状态保存到磁盘

[英]In WinForms .NET C#, how to save to disk the state of a TreeView control

For a .NET 3.5 VS2008 treeview control, where the item labels are set to be editable, how do I save the changes to disk so that I can load them up again when the application restarts? 对于.NET 3.5 VS2008树视图控件,其中项目标签设置为可编辑的,如何将更改保存到磁盘,以便在应用程序重新启动时再次加载它们?

Thanks 谢谢

是一篇有关使用XmlTextWriter和XmlTextReader序列化和反序列化TreeView控件的文章。

You have to use a serializer .... binary serializers are the fastest and most efficient but are not widely support by non .Net platforms but they support Serializaition events so you get more granualr control over the serialization process. 您必须使用序列化器....二进制序列化器是最快,最有效的,但非.Net平台并未广泛支持,但是它们支持Serializaition事件,因此您可以对序列化过程进行更严格的控制。 Use a serializer of your choice to save the state or programmitically do it the long way by using a confile file and save all the expanded nodes and re draw it manually. 使用您选择的序列化程序来保存状态,或者通过使用confile文件以编程方式长时间保存状态,并保存所有展开的节点并手动重新绘制。 This is a worthwhile academic excerise but not the best way of doing it. 这是一个值得的学术练习,但不是最好的方法。

Serialization is a big chapter, read up on it and choose the class that meets your needs. 序列化是重要的一章,请仔细阅读并选择满足您需求的类。 Remember if your application is goiong to be working with non.Net platforms then XML is the way to go or SOAP !!! 请记住,如果您的应用程序可以与非.Net平台一起使用,那么XML是使用SOAP的方法!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM