使用IsolatedStorage问题保存CheckBox(vb) [英] CheckBox saved with IsolatedStorage Problem (vb)

查看:83
本文介绍了使用IsolatedStorage问题保存CheckBox(vb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





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



亲切的问候







 私人  Sub  Button2_Click(sender  As  System。 Object ,e  As  System.Windows.RoutedEventArgs)句柄 Button2.Click 

' Rem保存设置'

如果 CheckBox1.IsChecked = True 然后
IsolatedStorageSettings.ApplicationSettings( MyCheckBox)= CheckBox1.IsChecked = True

ElseIf CheckBox1.IsChecked = False 然后
IsolatedStorageSettings.ApplicationSettings( MyCheckBox)= CheckBox1.IsChecked = False

结束 如果

结束 Sub



私有 Sub Button3_Click(发件人 As 系统。 Object ,e As System.Windows.RoutedEventArgs) Handles Button3.Click

' Rem Call Up Saved Settings'

MessageBox.Show( 选择Tank Procedure First

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


结束 Sub

解决方案

这个答案是由Karmjit Singh给我的来自Microsoft Silverlight Forunm





 私人  Sub  Button1_Click(发件人作为系统。对象,e  As  System.Windows.RoutedEventArgs)句柄 Button1.Click 

如果 IsolatedStorageSettings.ApplicationSettings.Contains( MyCheckSettings然后
IsolatedStorageSettings.ApplicationSettings( MyCheckSettings)= CheckBox1.IsChecked
Else
IsolatedStorageSettings.ApplicationSettings.Add( MyCheckSettings,CheckBox1.IsChecked)
结束 如果


结束 Sub

私有 Sub Button2_Click(发件人< span class =code-keyword> As System。 Object ,e As System。 Windows.RoutedEventArgs)句柄 Button2.Click

Dim x As 布尔值?

IsolatedStorageSettings.ApplicationSettings.TryGetValue( 布尔?)( MyCheckSettings,x)
CheckBox2.IsChecked = x
End


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

解决方案

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


这篇关于使用IsolatedStorage问题保存CheckBox(vb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆