)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use the WinForms Docking Manager to dock an embedded web browser in a form?

Platform: WinForms |
Control: DockingManager |
Published Date: April 30, 2011 |
Last Revised Date: December 6, 2019

Embedded web browser

The embedded web browser cannot be docked like a regular dockable control. This is because the docking windows layout initialization attempts to access the web browser’s handle while that control is still in the process of being created which could result in a System.Reflection.TargetInvocationException. This happens with other ActiveX wrappers too. The ActiveX control handle sometimes gets created more than once during initialization and this interferes with the re-parenting that takes place when a dock state is being loaded. An easy workaround to this would be set a panel control as the docking window and use this as a place holder, instead of directly enabling docking on the ActiveX control.

Handle the Docking Manager's NewDockStateEndLoad event, parent the ActiveX control to the panel, and set its desired DockStyle value.

C#

private void dockingManager1_NewDockStateEndLoad(object sender, System.EventArgs e)
{
   object o=null;
   // panel1 is the docking window and label1 is the HTML control
   this.panel1.Controls.Add (this.label1);
   this.label1.Dock = DockStyle.Fill;
   this.axWebBrowser1.Navigate("http://www.syncfusion.com",ref o,ref o,ref o,ref o);
}

 

VB

Private Sub dockingManager1_NewDockStateEndLoad(ByVal sender As Object, ByVal e As System.EventArgs)
    ' panel1 is the docking window and label1 is the HTML control
    Dim o As Object = Nothing
    Me.panel1.Controls.Add (Me.label1)
    Me.label1.Dock = DockStyle.Fill
    Me.AxWebBrowser1.Navigate("http://www.syncfusion.com", o, o, o, o)
End Sub

 

Reference link: https://help.syncfusion.com/windowsforms/dockingmanager/docking-events#notify-dock-state-change

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon