! Help ! How to save user setting on program exit
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts
Page 1 of 1
How would I go about saving the users settings of check boxes upon program exit using My.Settings.Save
I have on the form
1 textbox namedtxt1
3 checkboxes named chBox1-3
I want to save the current state of all these object when the program closes with out using a "save" button
Thanks in advance
P.s. I am using Visual Studio 2008
I have on the form
1 textbox namedtxt1
3 checkboxes named chBox1-3
I want to save the current state of all these object when the program closes with out using a "save" button
Thanks in advance
P.s. I am using Visual Studio 2008
You can make settings with the type string and Boolean, and when the app is closing (on the form#_closing event) change all of the settings to the values of the textbox/checkboxes. after you set the values, use my.settings.save()
Thank you for the quick reply. But I would like a coding example for the check boxes specifically. Here is what i have so far and its not working
thanks again
Code: Select all
Public Class Form1
Dim Settings As New My.MySettings
Dim chBox1 As New My.MySettings
Dim chBox2 As New My.MySettings
Dim chBox3 As New My.MySettings
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
My.Settings.chBox1 = Me.chboxItem1.CheckState
End Sub
thanks again
Code: Select all
is that what you mean? and where its says me.chboxItem1 i dont think you need mePrivate Sub Form1_Formclosing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosing
End Sub
but after that line
My.Settings.chBox1 = Me.chboxItem1.CheckStatewrite my.settings.save
Last edited by Bogoh67 on Mon Nov 14, 2011 2:33 pm, edited 1 time in total.
Mr.Wilson wrote:Thank you for the quick reply. But I would like a coding example for the check boxes specifically. Here is what i have so far and its not working
Code: Select allMy.Settings.chBox1 = Me.chboxItem1.Checked My.Settings.Save
! Solved ! There might be other ways to do this but this is how I did it. before I close this topic i would like someone to check it so as not to post poor info.
Code: Select all
Thanks again for every ones help.Public Class Form1
Dim chBox1Settings As New My.MySettings
Dim chBox2Settings As New My.MySettings
Dim chBox3Settings As New My.MySettings
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
chBox1.Checked = My.Settings.chBox1Settings
chBox2.Checked = My.Settings.chBox2Settings
chBox3.Checked = My.Settings.chBox3Settings
End Sub
Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
My.Settings.chBox1Settings = chBox1.CheckState
My.Settings.chBox2Settings = chBox2.CheckState
My.Settings.chBox3Settings = chBox3.CheckState
My.Settings.Save()
Close()
End Sub
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End Sub
End Class
Code: Select all
You dont need the Dim chBox1Settings As New My.MySettings... Its enough with just My.Settings.chBox1SettingsPublic Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
chBox1.Checked = My.Settings.chBox1Settings
chBox2.Checked = My.Settings.chBox2Settings
chBox3.Checked = My.Settings.chBox3Settings
End Sub
Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
My.Settings.chBox1Settings = chBox1.CheckState
My.Settings.chBox2Settings = chBox2.CheckState
My.Settings.chBox3Settings = chBox3.CheckState
My.Settings.Save()
Close()
End Sub
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End Sub
End Class
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023