Click here to Skip to main content
11,720,324 members (80,607 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows Forms
C# Windows Form Application project. I have a menu form which has buttons to load other already created forms.

private void cmdReporting_Click(object sender, EventArgs e)
    reporting frm = null;
    if ((frm = (reporting)openCheck(typeof(reporting))) == null)
        frm = new reporting();

The form it is trying to load is named reporting. This code is identical to WORKING code that loads other forms. This is the only one out of 5 that won't load. It does not throw an error either.

Is there a setting I'm missing in the GUI?

Added Code for openCheck method
public static Form openCheck(Type FormType)
    foreach (Form OpenForm in Application.OpenForms)
        if (OpenForm.GetType() == FormType)
            return OpenForm;
    return null;
Posted 25-Aug-12 9:23am
Edited 25-Aug-12 9:31am
Zoltán Zörgő at 25-Aug-12 15:28pm
What is "loading a form"? Show method will show a visible or hidden form, Select activates a visible form. But Show is not modal. What is the source of openCheck? How are the forms closed?
Wes Aday at 25-Aug-12 15:30pm
Did you debug it to find if the form is being created? If not created then what error is causing the creation to fail?
Christian Graus at 25-Aug-12 20:54pm
No - he thinks the debugger only works when your code blows up.
Wes Aday at 25-Aug-12 21:31pm
OMG, I see... Well CG... it's hard to help people that do not listen. I like the "working code does not trip the debugger"....
Zoltán Zörgő at 25-Aug-12 16:01pm
I would rather use the singleton pattern, like here:
joeswindell at 25-Aug-12 21:51pm
Thank you Zoltan, that would be a much better solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 2,029
1 OriginalGriff 844
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540

Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 25 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100