Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I have a problem loading the saved setting of a CheckBox (Checked True or False). On calling up the saved setting it always comes back as True from IsolatedStorage weather the CheckBox has been checked or not? Please see the code attached and I would appreciate it if someone could show me the error of my ways.
 
Kind regards
 
Will
 
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
 
        'Rem Save Settings'

If CheckBox1.IsChecked = True Then
IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = True
 
ElseIf CheckBox1.IsChecked = False Then
IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = False
 
End If
 
End Sub
 

 
Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click
 
        ' Rem Call Up Saved Settings'

        MessageBox.Show("Choose Tank Procedure First")
 
CheckBox1.IsChecked = (IsolatedStorageSettings.ApplicationSettings("MyCheckBox"))
 

End Sub
Posted 1-Dec-12 10:03am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This answer was kindly given to me by Karmjit Singh from the Microsoft Silverlight Forunm
 

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
 
      If IsolatedStorageSettings.ApplicationSettings.Contains("MyCheckSettings") Then
         IsolatedStorageSettings.ApplicationSettings("MyCheckSettings") = CheckBox1.IsChecked
      Else
         IsolatedStorageSettings.ApplicationSettings.Add("MyCheckSettings", CheckBox1.IsChecked)
      End If
 

   End Sub
 
   Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
 
      Dim x As Boolean?
 
      IsolatedStorageSettings.ApplicationSettings.TryGetValue(Of Boolean?)("MyCheckSettings", x)
      CheckBox2.IsChecked = x
   End Sub
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100