I want to save a value from a TextBox, an item of text from the SelectedIndex of a ComboBox and a CheckBox checked true or false. I then want to recall the saved settings with the OnClick from a button. I’ve had a go with the TextBox below but I get the following error statement: KeyNotFoundException was unhandled by user code. The given Key was not in the present dictionary?
Can anybody help me?
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
The ApplicationSettings works similar to a Hashtable. It requires a key to identify any setting you wish to store.
You can store your setting like this (air code):
And you can retrieve your setting like this:
You can read more about the ApplicationSettings on MSDN