[英]How to get items in listbox in to Settings.Default C#
我试图在Settings.Default中保存列表框中的项目,但它不起作用,这是我到目前为止。
test.Properties.Settings.Default.list = listBox1.Items;
如果之后不调用Save()
,则属性的更改将不会保留。
test.Properties.Settings.Default.list = listBox1.Items;
test.Properties.Settings.Default.Save();
你试过过ArrayList
吗?
test.Properties.Settings.Default.list = new ArrayList(listBox1.Items);
test.Properties.Settings.Default.Save();
然后你可以像这样加载列表:
listBox1.Items.AddRange(test.Properties.Settings.Default.list.ToArray());
我还假设列表中的项目是可序列化的(实现ISerializable
或具有SerializableAttribute
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.