Help needed with some code

Hi,

I have 2 forms, the main form is called MainForm and a dialog form is called frmSettings.

On the MainForm I have a schedulerControl, and on frmSettings a checkbox called chkShowMin.

What I want is when the user clicks on the checkbox chkShowMin, and presses the OK-button
the property ShowMinutes of the schedulerControl will be displayed, and offcaurse when the
user uncheck the checkbox the property ShowMinutes will be hidden. The setting of the checkbox
showmin will be loaded and saved to a inifile.

THAT ALL WORKS GREAT.

But what I want next is when the user starts my programm
That in the load-event will check if the property ShowMinutes
is set to true or false. If its true then show the minutes on the
schedulercontrol if not the hide the minutes.

I don't get that part right. Who can help me fix this?

Peter
FRMSETTINGS:

        private bool _ShowMin;

        private void btnOK_Click(object sender, EventArgs e)
        {
            {
                ShowMin = chkShowMin.Checked;
            }
            this.Close();
        }

        public bool ShowMin
        {
            get { return _ShowMin; }
            set { _ShowMin = value; }
        }

MAINFORM:

        private void MainForm_Load(object sender, EventArgs e)
        {
         if (frmSettings.ShowMin) { schedulerControl.DayView.TimeRulers[0].ShowMinutes = false; }  <==NOT GOOD
         else { schedulerControl.DayView.TimeRulers[0].ShowMinutes = true; }                              <==NOT GOOD

Open in new window

LVL 1
Peter KiersOperatorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Curious:

  You defined the property with the name "ShowMin" in FRMSETTINGS, but in MAINFORM you are trying to access "ShowMinutes". Is this just a copy/paste error or typo when creating the question?
0
ALaRivaCommented:
The problem is that you aren't loading the value that is saved in the INI file. What you need to be doing is in the load, you can check the value of the INI file, and use that to set it.

Then, you also need to do similar in the settings form. When it loads, you need to check the box (or not) depending on  the value saved in the INI and then set the settings form  checkbox appropriately.

hth

- Anthony
0
jdavistxCommented:
Also, is there any reason inparticular you're using an INI file?  It's my understanding that .NET doesn't provide any direct facilities for manipulating INI files; however, you could achieve a similar result with an XML file and I imagine with a lot less effort.  

You'd also be able to take advantage of things like Linq-to-XML:
http://msdn.microsoft.com/en-us/library/bb387061.aspx

Just something to consider.
0
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
...and I would use a Setting to store that single boolean value:
http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx
0
Peter KiersOperatorAuthor Commented:
jdavistx, can you show me how?
0
Peter KiersOperatorAuthor Commented:
I have to think, because I have no idea after getting all that response what to do.
I want to fix my problem with a lot less effort.
0
Peter KiersOperatorAuthor Commented:
I have a question for Idle_Mind:

When i use a Setting do i have to do that on both forms?

P.
0
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
The setting is for the whole application...it can be read from anywhere.  So you'd read that value on form load so you know what the last state was and you'd read it when the settings form is opened so you know how to display it to the user.  You'd also read it after the settings form is closed (back in the main form) so you can update the state of the visual control.
0
Peter KiersOperatorAuthor Commented:
IDLE MIND: You mean the Setting is for the mainform and all the other forms.
In other words all forms?

P.
0
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
The values being stored can be used by the forms...but they are not associated with any particular form.  They are associated with the application.

In the MSDN link I provided, take a close look at the section labeled "Using Settings at Run Time" as it has examples of how to read and write the settings.

For example, if you had created a bool setting called "ShowMinutes", you could read it with:
private void MainForm_Load(object sender, EventArgs e)
{
    schedulerControl.DayView.TimeRulers[0].ShowMinutes = Properties.Settings.Default.ShowMinutes;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter KiersOperatorAuthor Commented:
Thank you everyone for the information.
Peter
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.