Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Question about Settings-editor

Hi,

I have main form called MainForm and a dialogform called frmSettings.
on the frmSettings form i have a checkbox called chkShowMin

I have entered the values of the chkShowMin in the settings-editor:

chkShowMin - bool - User - True

But when I execute my programm the checkbox isn't checked and i have
set it to true in the editor.

What do I do wrong?

P.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

In the Load() event for frmSettings you need to set the state of your CheckBox; there is no "link" between the setting the and the control:
private void frmSettings_Load(object sender, EventArgs e)
{
    chkShowMin.Checked = Properties.Settings.Default.chkShowMin;
}

Open in new window

Avatar of Peter Kiers

ASKER

I have this:

        private void Settings_Load(object sender, EventArgs e)
        {
            this.chkShowMin.Checked = Properties.Settings.Default.ShowMin;

        }

        private void Settings_FormClosed(object sender, FormClosedEventArgs e)
        {
            Properties.Settings.Default.ShowMin = this.chkShowMin.Checked;

        }

But it isn't all is it. What do I have to do more...


Peter
I have to put something here, i think:

        private void btnOK_Click(object sender, EventArgs e)
        {
            {
              xxx
            }
            this.Close();
        }
When closing, after setting the value, you need to Save them:
private void Settings_FormClosed(object sender, FormClosedEventArgs e)
        {
            Properties.Settings.Default.ShowMin = this.chkShowMin.Checked;
            Properties.Settings.Default.Save();
        }

Open in new window


Back in the main form, after the settings form closes, you'd need to update the ShowMinutes() property on your control.  If you displayed settings from with ShowDialog() then you could place this line directly after that to make it update:
// In main form, after the "settings" ShowDialog() line:
schedulerControl.DayView.TimeRulers[0].ShowMinutes = Properties.Settings.Default.ShowMin;

Open in new window

I have this, but i doesn't work:

        private void Settings_Load(object sender, EventArgs e)
        {
            this.chkShowMin.Checked = Properties.Settings.Default.ShowMin;

        }

        private void Settings_FormClosed(object sender, FormClosedEventArgs e)
        {
            Properties.Settings.Default.ShowMin = this.chkShowMin.Checked;

        }

When I check my checkbox and close the frmSettings and then the application.
And then start my app again and open the frmSettings the chkShowMin is not checked???

What do I do wrong?

P.
See my last post...you need to call Save() to update the values.  (line #4 in the first snippet)
Oke, one little last Q.

When I click on the OK-button of the frmSettings-form.
and the chkshowmin was true then show the property
ShowMinutes (=true)
and if the chkshowmin was false then hidethe property
ShowMinutes (=false)

Could you help me with this before i give you the points.

P.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I give you allready the points. Because I got to go.
Thank you for your help.

Peter