When LoadContent Form_Load Event isn't called

4 posts, 0 answers
  1. Sari
    Sari avatar
    5 posts
    Member since:
    Sep 2011

    Posted 04 Oct 2011 Link to this post

    I use LoadContent method to load content of my form, but  Form_Load Event isn't called. Any help?

    HostWindow hw;
    Form f = GetFormHostWindow(hw.Name);
    if (f != null) hw.LoadContent(f);
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 Oct 2011 Link to this post

    Hello Sari,

    Yes, you have a couple of options.
    First, move everything from Load to the forms constructor.
    Second, after creating the form Form f = ...
    register for f.Show += .... event an then in that event call hw.LoadContent(f)

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. DevCraft banner
  4. Sari
    Sari avatar
    5 posts
    Member since:
    Sep 2011

    Posted 07 Oct 2011 Link to this post

    Thank you.

  5. Jack
    Jack avatar
    2335 posts

    Posted 07 Oct 2011 Link to this post

    Hello Sari,

    Thank you for contacting us. 

    The purpose of the LoadContent method is just to load a control in a HostWindow and if this control is a form - to strip its titlebar. If your form has already been loaded once, the LoadContent will not cause the form to fire its Load event again. Here is a usage of the LoadContent where the Load event of the form is fired as expected, because the form is loaded for the first time in the application:
    private void radButton1_Click(object sender, EventArgs e)
        HostWindow h = this.radDock1.DockControl(new RadButton(), DockPosition.Left);
        Form f = new Form();
        f.Load += new EventHandler(f_Load);
    void f_Load(object sender, EventArgs e)
        throw new NotImplementedException();

    If you have additional questions, feel free to write back.
    Best wishes,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top