Click here to Skip to main content
15,615,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Category Overview form which will save the defect category typed by the user. The defect categories will be insert to the CheckedListBox. However, the defect category added previously in the list will disappear when the page is close. My question is how can I save it and load the values when the page is open again? I have tried Properties.Settings.Default.Save(), but it’s not working. Please Help :(

What I have tried:

Updated 7-Jul-22 18:57pm
GKP1992 8-Jul-22 0:43am    
Have you tried googling your issue? There are some search results which could prove useful to you.

Calling Save doesn't do anything without a field in the settings to actually store the data in, and your code changing that setting first - you also have to load the settign value into your code when you load the from.
For example:
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
    if ((ModifierKeys & Keys.Shift) == 0)
    Properties.Settings.Default.UptoFirstComma = cbUpToFirstComma.Checked;

private void FrmMain_Shown(object sender, EventArgs e)
    cbUpToFirstComma.Checked = Properties.Settings.Default.UptoFirstComma;
But if you are using a collection, then you probably don't want to store it in Settings - a data file may be a lot more appropriate, since there is only one set of Properties.Settings per application / assembly.

I don't know what data you are trying to store, or how often it gets changed, but you might want to work out your data flow before going this route, and decide if you should use an external file (XML, JSON, or even CSV) instead, or if a full database would be more appropriate. We can't make that decision for you!
Share this answer
U can try to use
and save the values using
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900