10-12-2011, 08:15 PM
This is a really useful way to save the users settings in your apps. Ive seen other ways which are good but this works for me.
1. Create a New project call it whatever you want, I named mine "MySettings".
2.Add a Textbox and Button control to your app.
The buttons text should read "Save".
On the textbox, I set to multiline.
3. Click on My Project in the soultion explorer
4. Click the Settings Tab
5. Add a new "Name" for your setting, this name will be used kinda like a variable. I named mine textsaved.
6. Under the "Type" column click "String" I actually think this is by default. Now you could use the other Data types as well, depending on what your really trying to save.
7. Under scope you want "User" scope cause its the user saving not the "Application".
8. Optional: depending on the setting, for "value" it would be a text value since where using a string type. But for now just leave it blank cause where going to fill that up with user input.
Heres the code where going to use:
So starting typing some non-sense in the textbox.
Then click the save button and close the app.
Reopen the app and bam your text appears. Try it without clicking the save button and you get nothing.
Basicly in the button click event we are going to save the text in the textbox. Where not really saving the data yet just assigning it to the setting we made.
In the form closing we are actually saving. If you forget this line it will not save.
On the form load we are telling the textbox that its contents will be what was saved from the setting.
Well thats all there is to it. Hope this helps someone here.
1. Create a New project call it whatever you want, I named mine "MySettings".
2.Add a Textbox and Button control to your app.
The buttons text should read "Save".
On the textbox, I set to multiline.
3. Click on My Project in the soultion explorer
4. Click the Settings Tab
5. Add a new "Name" for your setting, this name will be used kinda like a variable. I named mine textsaved.
6. Under the "Type" column click "String" I actually think this is by default. Now you could use the other Data types as well, depending on what your really trying to save.
7. Under scope you want "User" scope cause its the user saving not the "Application".
8. Optional: depending on the setting, for "value" it would be a text value since where using a string type. But for now just leave it blank cause where going to fill that up with user input.
Heres the code where going to use:
So starting typing some non-sense in the textbox.
Then click the save button and close the app.
Reopen the app and bam your text appears. Try it without clicking the save button and you get nothing.
Basicly in the button click event we are going to save the text in the textbox. Where not really saving the data yet just assigning it to the setting we made.
In the form closing we are actually saving. If you forget this line it will not save.
On the form load we are telling the textbox that its contents will be what was saved from the setting.
Well thats all there is to it. Hope this helps someone here.