如何将列表框项目保存到文件 [英] How to save listbox items to file

查看:69
本文介绍了如何将列表框项目保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想将我的列表框项目保存到文件中,这样当我关闭表单时它会保存,这样当我打开时应用程序列表框中的项目将重新加载,它们将在那里。我需要在form1_closed事件中有代码。另外
如果有任何方法可以保存然后列出框项目,(除了数据库)我想知道如何。代码会有所帮助。


谢谢,

解决方案


对列表框中的对象使用序列化。


https://msdn.microsoft.com/en-us/library/7ay27kt9(v = vs.110)。 aspx


https://msdn.microsoft.com/en-us/library/szzyf24s(v = vs.110).aspx


https ://msdn.microsoft.com/en-us/library/ms973893.aspx


问候,


 的Thorsten


Hi,

I would like save my listbox items to a file, so that when I close the form it will at that time save, so that when I open the app the items in the listbox will reload and they will be there. I would need to have the code in the form1_closed event. Also if there is any way to save then listbox items, (other than database) I would like to know how to. The code would help.

Thanks,

解决方案

Hi,

use Serialization for the objects in your listbox.

https://msdn.microsoft.com/en-us/library/7ay27kt9(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/szzyf24s(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/ms973893.aspx

Regards,

  Thorsten


这篇关于如何将列表框项目保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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