This is a migrated thread and some comments may be shown as answers.

When LoadContent Form_Load Event isn't called

3 Answers 54 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sari
Top achievements
Rank 1
Sari asked on 04 Oct 2011, 01:49 PM
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);

3 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 06 Oct 2011, 02:56 PM
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
0
Sari
Top achievements
Rank 1
answered on 07 Oct 2011, 10:59 AM

Thank you.

0
Jack
Telerik team
answered on 07 Oct 2011, 04:48 PM
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);
    h.LoadContent(f);
}
 
void f_Load(object sender, EventArgs e)
{
    throw new NotImplementedException();
}

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

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

Tags
Dock
Asked by
Sari
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Sari
Top achievements
Rank 1
Jack
Telerik team
Share this question
or