I want to have two different browser windows loaded one below the other on the same form in Visual studio. I can load one browser window and keep it half way up top, with sizes and locations specified. When I add a second browser window below the first one, I am missing something. I am not a programmer, just learning. So, I don't know what I am doing wrong.
Here is the code
public Form1()
{
InitializeComponent();
InitBrowser();
InitBrowser2();
this.WindowState = FormWindowState.Maximized;
}
public ChromiumWebBrowser browser1;
public void InitBrowser()
{
Cef.Initialize(new CefSettings());
browser1 = new ChromiumWebBrowser("https://www.google.com/");
this.Controls.Add(browser1);
browser1.Location = new Point(0, 0);
browser1.Anchor = (AnchorStyles.Top);
browser1.Size = new Size(1300, 400);
}
public ChromiumWebBrowser browser2;
public void InitBrowser2()
{
Cef.Initialize(new CefSettings());
browser2 = new ChromiumWebBrowser("https://www.yahoo.com/");
this.Controls.Add(browser2);
browser2.Location = new Point(0, 400);
browser2.Size = new Size(1300, 400);
}
when I load only the
InitBrowser1();
inside the
public Form() {}
it loads. but when i put the
InitBrowser2();
only the first one shows up, not the second one. What am I doing wrong? Is there any other way that I can have two browser windows loaded on one form?
Edit: I found a way to load both browsers on one form. I changed the code as below. The only problem now is they do not align properly, they show overlapping on each other. Any help on how to have one on the top half of the page and the other to the bottom half of the page?
public ChromiumWebBrowser browser;
public ChromiumWebBrowser browser2;
public void InitBrowser()
{
Cef.Initialize(new CefSettings());
browser1 = new ChromiumWebBrowser("https://www.google.com/");
this.Controls.Add(browser1);
browser1.Location = new Point(-300, 0);
browser1.Size = new Size(1300, 400);
browser2 = new ChromiumWebBrowser("https://www.yahoo.com");
this.Controls.Add(browser2);
browser2.Location = new Point(-300, 400);
browser2.Size = new Size(300, 400);
}