I guess I"m a little confused as to what conditions you could create where you would being opening a form what wasn't "new". I'm not really sure what you mean by new? Are you trying to create a form that can only open one instance?
If so I'm not so sure I would try to put that code in the form. You have to create the second instance in order to have a .Loading() which is where you check exists. That means you allocate time, memory, resources, objects to the creation of a second instance whether you intend to use it or not. Why create all that just to delete it again? If your CALLING code checks to see if it already exists it can keep a second instance from every being created.
Had you considered only creating one instance of the form then using the ".Show()" and ".Hide()" methods? Thus it always exists, it just may not be visible.
Quote:
As menetioned in original post, if I try
txtC1 == "false" or txtC2 == "false" or txtC3 == "false" individually, I get the desired result (form doesn't open)
Right, because at least one really is equal to "false" EXACTLY. You said that if you only checked txtC1 that it worked fine. This would indicate that txtC2 or txtC3 is not really an EXACT match for "false".
Another way to diagnose it might be to output those three variables to the console just before you check them.
Or nest your 'if' statements so you can better find the mismatach
- if (txtC1.Text.ToLower().Contains("false"))
-
{
-
console.Writeline("1 matched");
-
if (txtC2.Text.ToLower().Contains("false"))
-
{
-
console.Writeline("2 matched");
-
if (txtC3.Text.ToLower().Contains("false))
-
{
-
// This can only be reached if all three match
-
}
-
}
-
}
-
}