[英]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.