Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

VB
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 solution

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


VB
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900