我想保存TextBox
中的值,SelectedIndex
中ComboBox
的{{1}}和CheckBox
选中的真或假。然后,我想从一个按钮调用OnClick
保存的设置。我已经使用下面的TextBox
,但是我收到以下错误声明:KeyNotFoundException
未被用户代码处理。给定的密钥不在现在的字典中?
有人能帮助我吗?
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
Dim Store As IsolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings
IsolatedStorageSettings.ApplicationSettings(TextBox1.Text) = TextBox1
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click
TextBox1 = (IsolatedStorageSettings.ApplicationSettings(TextBox1.Text))
End Sub
答案 0 :(得分:0)
ApplicationSettings的工作方式类似于Hashtable。它需要一个键来识别您想要存储的任何设置。
您可以像这样存储您的设置(航空代码):
IsolatedStorageSettings.ApplicationSettings("MyTextBoxKey") = TextBox1.Text
您可以像这样检索您的设置:
TextBox1.Text = CStr(IsolatedStorageSettings.ApplicationSettings("MyTextBoxKey"))