If I read your question correctly, you would need a separate class where you store your preferences, This class could be even static which would help in handling the preferences. For example (pseudo code):
public static class Preferences {
public int FontSize { get; set; }
...
}
Now you can modify the preferences directly from your window.
Preferences.FontSize = 123;
If you want to react on the changes in another form you can use events for that. For example (pseudo again):
public static class Preferences {
public static EventHandler SomethingHasChanged;
public int FontSize {
get {
...
}
set {
...
EventHandler theEvent = SomethingHasChanged;
if (theEvent != null) {
theEvent();
}
}
...
Just remember that when you subscribe the event in an instance (for example in a form), you must also unsubscribe it when the form is closed. Otherwise the reference isn't cleaned because the event publisher is static.
If you wish, you can save the information in your preferences into a file etc. One way is to serialize it to a file. One good example:
http://www.switchonthecode.com/tutorials/csharp-tutorial-serialize-objects-to-a-file[
^]
Addition (example)
First add a new static class to the project:
public static class Preferences {
public static event System.EventHandler PrefChanged;
private static bool _someSetting = false;
public static bool SomeSetting {
get {
return Preferences._someSetting;
}
set {
Preferences._someSetting = value;
if (PrefChanged != null) {
PrefChanged(null, new System.EventArgs());
}
}
}
}
Now in the Form1 where you want to receive changes in the preferences add for example to constructor:
Preferences.PrefChanged += new System.EventHandler(Preferences_PrefChanged);
And a method to this form:
public void Preferences_PrefChanged(object sender, System.EventArgs e) {
this.TextBox1.Text = ("SomeSetting is now " + Preferences.SomeSetting.ToString());
}
And in the form2 where you modify settings, add to the click event of the checkbox:
Preferences.SomeSetting = this.checkBox1.Value;
Also somewhere where Form1 is closed you should add:
Preferences.PrefChanged -= new System.EventHandler(Preferences_PrefChanged);
After this if you run the program (there may be typos in the code blocks), whenever you change the value of the checkbox the textbox should show the current value of the setting.