Why does the application work only on double click?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Connelly
    New Member
    • Jan 2011
    • 103

    Why does the application work only on double click?

    I have a method that works, but when I click a link the first time the new form opens as it should. I then have in the method to check to see if the new form is open by using a bool variable. This works properly, but requires that I click the button twice before it will perform. What is causing this? Any Ideas or Suggestions? I have attached my code below for the Method.
    Code:
    private void lblClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                Form intiatedForm = null; /* creates an instance to a new form.  Used to open another form when called.*/
                if (openForm == false)
                {
                    intiatedForm = new frmClose();
                    intiatedForm.Show();
                    openForm = true;
                }
                else if (openForm == true)
                {
                    FormCollection _forms = Application.OpenForms;
                    foreach (Form a in _forms)
                    {
                        if (a is frmClose)
                        { openForm = true; }
                        else openForm = false;
                    }                
                } 
            }
  • Brian Connelly
    New Member
    • Jan 2011
    • 103

    #2
    The answer is in the code

    Hello dear readers, I found the answer. What was happening is that on thedouble clicking was that the first click my code was setting the bollean to false and doing nothing. Then because the the boolean variable was set to false, the second click executed the code for the false bool.

    Comment

    Working...