CefSharp WinForms Web浏览器不会显示 [英] CefSharp WinForms Web Browser Won't Display

查看:334
本文介绍了CefSharp WinForms Web浏览器不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的示例,试图让CEF浏览器附加到Winforms表单上。

I have a dead simple example trying to get the CEF Browser to append on a Winforms Form. For some reason it won't display.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        CefSharp.WinForms.ChromiumWebBrowser test = new CefSharp.WinForms.ChromiumWebBrowser("http://google.com");
        this.Controls.Add(test);
    }
}

下面是我正在使用的VS解决方案。我通过 Nuget

Below is the VS Solution I am using. I added the package via Nuget

推荐答案

上面的代码有点太简单了:)

Your code above is a bit too dead simple :)

它缺少对<$的调用c $ c> Cef.Initialize()

请参见 Main()方法 CefSharp.MinimalExample.WinForms 示例中的示例,以及有关如何使用CefSharp的更多详细信息。

See the Main() method of the CefSharp.MinimalExample.WinForms example for a working example and further details on how to use CefSharp.

您还需要给控件一个 DockStyle.Fill ,例如:

You also need to give the control a DockStyle.Fill, like:

public Form1()
{
    InitializeComponent();
    var test = new CefSharp.WinForms.ChromiumWebBrowser("http://google.com")
    {
        Dock = DockStyle.Fill,
    };
    this.Controls.Add(test);
}

这篇关于CefSharp WinForms Web浏览器不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆