MDI Child Form System Exception

5 posts, 0 answers
  1. Gary
    Gary avatar
    18 posts
    Member since:
    Jul 2016

    Posted 16 Jun Link to this post

    I doubt that this is an issue with the WinForms controls but I'll ask anyway in case anyone has experienced this problem (and I haven't found any solution searching the web).  My project is MDI with seven child forms so far.  After a few months of development I finally experienced a problem when I select several of my menu options (launch several child forms).  It doesn't matter what the order I select the menu options; the third menu option, whichever option that happens to be, gets a System.NullReferenceException.

    The code for each menu option is this pattern:

    private void miDULAudit_Click(object sender, EventArgs e)
    {
        if (objDULAudit == null)
        {
            objDULAudit = new frmDULAudit();
            objDULAudit.MdiParent = this;
            objDULAudit.FormHiding += new EventHandler(ChildFormHiding);
        }
        objDULAudit.Show();
        objDULAudit.BringToFront();
        objDULAudit.Activate();
        objDULAudit.WindowState = FormWindowState.Maximized;
    }

     

    The error happens at objDULAudit.Show(); (in this code example).  

    System.NullReferenceException was unhandled
      HResult=-2147467261
      Message=Object reference not set to an instance of an object.
      Source=System.Windows.Forms
      StackTrace:
           at System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      InnerException: 

     

    I stepped through every line of code (as the child form instantiates) trying to run into the problem but I have not been successful.

    Any ideas?

    Thank you,

    Gary

     

     

  2. Gary
    Gary avatar
    18 posts
    Member since:
    Jul 2016

    Posted 16 Jun in reply to Gary Link to this post

    Update: I discovered that if the child forms are not maximized then this System.Exception doesn't happen.  For every menu option event handler I added a method to set all child forms to the normal window state and I can open every option without getting that error.  While I still want to fix the real problem, this work around helps.  There is the visual effect of the child form(s) switching from maximized to standard and then the selected child form maximizing.  I'd like to hide that.

     

    But I'm still searching for the real problem.

     

  3. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 19 Jun Link to this post

    Hello Gary,

    We had a report for an exception in the same method with a similar scenario. It appears however that it is not connected to our controls and the issue is in the .NET code. You can check the comments on our public item for detailed information: UI for Winforms Feedback Portal - FIX. RadForm - Exception when showing maximized MDI children with a lot of gauges.

    I hope this will be useful. 

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Gary
    Gary avatar
    18 posts
    Member since:
    Jul 2016

    Posted 19 Jun in reply to Dimitar Link to this post

    Dimitar,

    Thank you.  That is helpful; my work around is the solution and the problem is within .Net.  I couldn't find any confirmation in my searching on the web.  Your link is what I was looking for.

    Thank you,

    Gary

  5. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 20 Jun Link to this post

    Hello Gary,

    I am glad that this information was useful to you. Do not hesitate to contact us if you have other questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top