CefSharp.WinForms "Dock =DockStyle.Fill" no effect, black edge.how to make the ChromiumWebBrowser fill the TBForm?

Viewed 2430
public partial class TBForm : Form
{
    private readonly ChromiumWebBrowser browser;

    public TBForm()
    {
        InitializeComponent();

        browser = new ChromiumWebBrowser("www.baidu.com")
        {
            Dock = DockStyle.Fill,
        };

        this.Controls.Add(browser);
    }
}

i got this result

CefSharp.WinForms "Dock =DockStyle.Fill" no effect, black edge.

how to make the ChromiumWebBrowser fill the TBForm?

3 Answers

Do you tried disable the GPU engine using CefCommandLineArgs?

When you declare:

CefSettings settings = new CefSettings();

before initializations:

Cef.Initialize(settings);

Try to add the nex line of code:

settings.CefCommandLineArgs.Add("disable-gpu", "1");

Your windows screen resolution is not set to 100%. See the image below:

enter image description here

This is because CefSharp is using GPU to render and will depend on your screen resolution setting.

using this will fix the rendering to host display highest resolution:

Cef.EnableHighDPISupport();

And this will disable GPU rendering:

var settings = new CefSettings();
settings.CefCommandLineArgs.Add("disable-gpu", "1");
Cef.Initialize(settings);
Related