CefSharp WinForms web browser does not render
I have a simple example that tries to connect a CEF browser to a Winforms form. For some reason, it won't show up.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
CefSharp.WinForms.ChromiumWebBrowser test = new CefSharp.WinForms.ChromiumWebBrowser("http://google.com");
this.Controls.Add(test);
}
}
Below is the VS solution I am using. I added the package via Nuget
+3
source to share
1 answer
Your code above is too simple :)
Missing call Cef.Initialize()
Refer to Main()
the CefSharp.MinimalExample.WinForms
example method for a working example and more details on how to use CefSharp.
You also need to specify the control DockStyle.Fill
, for example:
public Form1()
{
InitializeComponent();
var test = new CefSharp.WinForms.ChromiumWebBrowser("http://google.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(test);
}
+19
source to share