Search code examples
c#winformsdotnetbrowser

How to assign new browser instance to WinFormBorwserView


I'm Trying to create new instance of a DotNetBrowser and assign it to my panel inside windows forms.

Based on DotNetBrowser start guide, to create new instance of browser (that have its own cache, etc) I need to do following:

   BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
   BrowserContext context1 = new BrowserContext(params1);
   Browser browser1 = BrowserFactory.Create(context1);

My question is, what do I do with this browser now? I want to asign it to my browserpanel like this

   browserpanel.Controls.Add(browser1);

But this will not work because I need to have object of a class WinFormsBrowserView to assign it to browserpanel. And If I create object of a type WinFormsBrowserView, I cant customize it as documentation explains. And the Browser inside newly constructed WinFormsBrowserView is readonly, so i cant assign this browser to it.


Solution

  • Found solution:

    BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
    context1 = new BrowserContext(params1);
    browser1 = BrowserFactory.Create(context1);
    WinFormsBrowserView  browserview = new WinFormsBrowserView(browser1);