Store the values in the registry. When the options form loads parse registry entries that dictate control state.. eg, dword reg entry chk1 = 0, checkbox loads unchecked, = 1, loads checked.
Another method is using the applications settings page, create a bool value, then access it through the forms.
bool ButtonVisible setting
this.btnOption.Visibile = Properties.Settings.Default.ButtonVisible;
Note you have to call: Properties.Settings.Default.Save(); after changing a value.
Here's a more complete example, including using the PropertyChanged event on the main form to propogate the change..
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Properties.Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged);
}
void Default_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
button1.Visible = Properties.Settings.Default.ButtonVisible;
this.Refresh();
}
private void button2_Click(object sender, EventArgs e)
{
frmOptions f = new frmOptions();
f.Show(this);
}
}
options form:
<pre lang="cs">
public partial class frmOptions : Form
{
public frmOptions()
{
InitializeComponent()
}
private void frmOptions_Load(object sender, EventArgs e)
{
Properties.Settings.Default.ButtonVisible = false
Properties.Settings.Default.Save()
}
}