How to use the WinForms Docking Manager to dock an embedded web browser in a form?
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