Save user settings for different users in WinForms?

576 Views Asked by At

I want to have a save preference option in my WinForms application. The user chooses yes/no and has an option to save preference, upon which the yes/no will be remembered and a form for such a choice will not be popped upon further re running the application.

I read about going to setting and changing but how to do it for different users, since all of them would choose for diff options and I need to maintain that.

Simply using a boolean variable will not help since it will be single user specific. Any suggestions?

3

There are 3 best solutions below

1
Vy Do On BEST ANSWER

(1) At event close main form, you call method/action save result. See How to save data when closing event happen in WinForms?

You can save it to XML file (or text file, SQL lite, SQL Server, etc), popular way is XML file(s).

Read XML file to get saved result before processing business logic in your WinForms application at Load form event or another event type at early stage of application start-up period.

(2) You also save result at previous period in config file https://stackoverflow.com/a/453230/3728901

Properties.Settings.Default["SomeProperty"] = "Some Value";
Properties.Settings.Default.Save(); // Saves settings in application configuration file
1
Sign On

you can use a Model and store use selected config into it then you should serilaize it and save on database for specific user when reRun the application you can get config and deserialize it to Model and use it

0
AudioBubble On

So since i didn't want a database , I am creating a file at the client side and saving the preference there. At run time , I will read from the file and upon that , will decide whether to send form or not .