【问题标题】:CheckBox Saved with IsolatedStorage (vb)使用独立存储 (vb) 保存的复选框
【发布时间】:2012-12-04 22:12:19
【问题描述】:

我在加载已保存的 CheckBox 设置时遇到问题(选中 True 或 False)。在调用已保存的设置时,它总是从 IsolatedStorage 天气中返回为 True,CheckBox 是否已被选中?请查看随附的代码,如果有人能告诉我我的方式的错误,我将不胜感激。

亲切的问候

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click

'Rem 保存设置'

如果 CheckBox1.IsChecked = True 那么

IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = True

ElseIf CheckBox1.IsChecked = False Then

IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = False

如果结束

结束子

    Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click

'Rem 调用保存的设置'

MessageBox.Show("先选择坦克程序")

CheckBox1.IsChecked = (IsolatedStorageSettings.ApplicationSettings("MyCheckBox"))

结束子

【问题讨论】:

    标签: silverlight silverlight-5.0


    【解决方案1】:

    这个答案是微软 Silverlight 论坛的 Karmjit Singh 给我的

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) 处理 Button1.Click

      If IsolatedStorageSettings.ApplicationSettings.Contains("MyCheckSettings") Then
         IsolatedStorageSettings.ApplicationSettings("MyCheckSettings") = CheckBox1.IsChecked
      Else
         IsolatedStorageSettings.ApplicationSettings.Add("MyCheckSettings", CheckBox1.IsChecked)
      End If
    

    结束子

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) 处理 Button2.Click

      Dim x As Boolean?
    
      IsolatedStorageSettings.ApplicationSettings.TryGetValue(Of Boolean?)("MyCheckSettings", x)
      CheckBox2.IsChecked = x
    

    结束子

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多