简体   繁体   English

将listBox的内容保存到程序设置C#

[英]Saving contents of a listBox to program settings C#

So what I am trying to do is save the contents from a listBox to the application Properties.Settings.Default I have no idea where to start, nor do I know if it is even possible. 所以我想做的是将内容从listBox保存到应用程序的Properties.Settings.Default我不知道从哪里开始,也不知道是否有可能。 Thanks in advance. 提前致谢。

any settings you have setup in Properties-> settings tab should show up like 您在“属性”->“设置”标签中设置的所有设置应显示为

[your namespace].Properties.Settings.Default.yoursetting = "change";

after you edit your properties always call 编辑属性后,始终调用

[your namespace].Properties.Settings.Default.Save();

the save part got me at first. 节省的部分起初让我着迷。

for list types use : 对于列表类型使用:

清单设定

it will help if your objects can be converted to and from strings anything more not really sure for anything more complex but I hope this gets you started. 如果您不能将对象转换为字符串,也可以将字符串转换为字符串,这将很有帮助,但是对于不确定的任何复杂操作,我不确定,但是我希望这可以帮助您入门。

foreach(string s in listbox.Items){[settingscode].add(s);}

something like that anyways. 反正就是这样

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

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