|
-
Oct 4th, 2010, 11:34 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Can some one explain this logic when setting a chks state reflecting on settings
Basically for a while now if i wanted to set a chks setting i would do this..
vb Code:
#Region "Properties"
'//Gets or sets a value that indicates if should close to tray.
Public Property ShouldCloseToTray() As Boolean
Get
Return chkCloseToTray.Checked
End Get
Set(ByVal value As Boolean)
chkCloseToTray.Checked = value
End Set
End Property
#End Region
Private Sub chkCloseToTray_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCloseToTray.CheckedChanged
My.Settings.CloseToTray = ShouldCloseToTray
End Sub
But thats a lot more noise then doing it this way
vb Code:
Private Sub chkCloseToTray_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCloseToTray.CheckedChanged
My.Settings.CloseToTray = chkCloseToTray.checked
End Sub
whats the pros cons and which way should i be doing it???
-
Oct 4th, 2010, 11:39 AM
#2
Re: Can some one explain this logic when setting a chks state reflecting on settings
save it with (ApplicationSettings).
after you've set it up (takes a few minutes) your checkbox value will be saved on exit + restored on startup automatically
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 4th, 2010, 11:43 AM
#3
Thread Starter
Fanatic Member
Re: Can some one explain this logic when setting a chks state reflecting on settings
Hello paul. Are you saying i dont have to have any code and VS has the function to save automatically???
Can you link me to where i can set this up please
thanks again
on a side note, what is the different between the 2 examples i gave?
-
Oct 4th, 2010, 11:51 AM
#4
Re: Can some one explain this logic when setting a chks state reflecting on settings
 Originally Posted by kayleigh
Hello paul. Are you saying i dont have to have any code and VS has the function to save automatically????
yes.
1/ select your checkbox in your form designer
2/ expand the (ApplicationSettings) property in the properties window
3/ select the (PropertyBinding) property + click the ellipsis to the right
4/ in the popup window, select the checked property + click the dropdown arrow to the right
5/ click New + in the new popup window, name the property + click ok on that window + ok on the window below + it's done
 Originally Posted by kayleigh
on a side note, what is the different between the 2 examples i gave?
they both do the same thing but 1 is a more roundabout way
Last edited by .paul.; Oct 4th, 2010 at 11:54 AM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 4th, 2010, 01:35 PM
#5
Thread Starter
Fanatic Member
Re: Can some one explain this logic when setting a chks state reflecting on settings
Cheers paul thats great, one more question though.
All my checkboxes are on frmOptions, which is only ever loaded if i need to change a setting.
If i needed to get that settings value right now i would just check the boolean value of my.settings.thatchkssavedsetting
if im not using my.settings any more how can i grab that settings value?
if i saved it as testchksetting
MessageBox.Show(Form2.CheckBox1.) ????
-
Oct 4th, 2010, 01:41 PM
#6
Re: Can some one explain this logic when setting a chks state reflecting on settings
 Originally Posted by kayleigh
If i needed to get that settings value right now i would just check the boolean value of my.settings.thatchkssavedsetting
to get the value whether the form with the checkbox is open or closed:
vb Code:
msgbox(my.settings.thatchkssavedsetting.tostring)
edit: an important note is that each (ApplicationSetting) must have a unique name. + you can access these values through my.settings
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 4th, 2010, 01:45 PM
#7
Thread Starter
Fanatic Member
Re: Can some one explain this logic when setting a chks state reflecting on settings
Thanks for the help. thats great, i can now remove a ton of coded lol
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|