2012-10-24 33 views
2

我想要保存TextBox中的值,ComboBoxCheckBoxSelectedIndex中的一项文本被检查为true或false。然后我想从一个按钮中调用OnClick保存的设置。我已经去了TextBox下面,但我得到以下错误声明:KeyNotFoundException未被用户代码处理。给定的密​​钥不在目前的字典中?在Silverlight 5(vb)中使用IsolatedStorage保存用户设置

任何人都可以帮助我吗?

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

ApplicationSettings的工作方式类似于Hashtable。它需要一个密钥来识别您希望存储的任何设置。

您可以将您的设置是这样的(空气代码):

IsolatedStorageSettings.ApplicationSettings("MyTextBoxKey") = TextBox1.Text 

而且你可以检索你的设置是这样的:

TextBox1.Text = CStr(IsolatedStorageSettings.ApplicationSettings("MyTextBoxKey")) 

您可以read more about the ApplicationSettings on MSDN

+0

感谢您的帮助凯利我应该能够从你的答案中解决所有问题。非常感激 – user1772044