Click here to Skip to main content
15,071,729 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i am trying to open 2 tabpages as default when user open my app. This is codes for just 1 tabpage:
C#
ChromiumWebBrowser chrome;
private void BrowserForm_Load(object sender, EventArgs e)
    {
        //initialize the browser
        this.initialize_browser();
        chrome.Parent = tabPage1;
    }
 private void initialize_browser()
    {
        CefSettings settings = new CefSettings();
        Cef.Initialize(settings);

        //main browser
        chrome = new ChromiumWebBrowser("http://google.com");
        tabPage1.Controls.Add(chrome);
        chrome.Dock = DockStyle.Fill;
    }


What I have tried:

And i tried something like this to add more tabpage:
Method 1:
C#
chrome.parent = tabpage1 = tabpage2;

Method 2:
C#
chrome.parent = tabpage1;tabpage2 = tabpage1;

Method 3:
C#
chrome.parent = tabpage1;
chrome.parent = tabpage2;

Both Method 1-2-3 have same private void initialize_browser()
C#
private void initialize_browser()
   {
       CefSettings settings = new CefSettings();
       Cef.Initialize(settings);

       //main browser
       chrome = new ChromiumWebBrowser("http://google.com");
       tabPage1.Controls.Add(chrome);
       chrome.Dock = DockStyle.Fill;

       tabPage2.Controls.Add(chrome);
       chrome.Dock = DockStyle.Fill;
   }

But all method just give one result that:" just have one tabpage is chrome.parent

I tried Method 4 also: create a new declare ChromiumWebBrowser chrome2; But chrome2 will have different setting with chrome. Example: all custom popupform of lifespanhanler just belong to chrome, and chrome2 will just use default.

Method 4:
C#
ChromiumWebBrowser chrome;

ChromiumWebBrowser chrome2;

private void BrowserForm_Load(object sender, EventArgs e)
    {
        //initialize the browser
        this.initialize_browser();
        chrome.Parent = tabPage1;
        chrome2.Parent = tabPage2;
    }
 private void initialize_browser()
    {
        CefSettings settings = new CefSettings();
        Cef.Initialize(settings);

        //main browser
        chrome = new ChromiumWebBrowser("http://google.com");
        tabPage1.Controls.Add(chrome);
        chrome.Dock = DockStyle.Fill;

        chrome2 = new ChromiumWebBrowser("http://google.com");
        tabPage2.Controls.Add(chrome);
        chrome2.Dock = DockStyle.Fill;
    }

Bro and Sense, how to me solve it? Thank you so much!
Post also posted on: c# - CEFSharp browser, open multi tabpages when open application - Stack Overflow[^]
Posted

1 solution

Estoy intentando lo mismo en una aplicacion de escritorio, sin embargo a veces me carga todos los chromiumWebBrowser a veces no, esta perdiendo los eventos y no se como agrearle o setearle al browser.load("root.html") un evento para siempre los dibuje, si lo resolviste te agradeceria...
   
Comments
Member 14036838 6-Sep-20 4:02am
   
english please ;D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900