CefSharp.Winforms 3.7,有没有办法在浏览器初始化或加载网页完成之后,再加入该浏览器Add到父容量

陌上骚猿 2014-12-12 05:45:43
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TileBrowserDemo.Custom;
using CefSharp.WinForms;

namespace TileBrowserDemo
{
public partial class MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
AddBreowser();
}

private void AddBreowser()
{
ChromiumWebBrowser b = new ChromiumWebBrowser("www.baidu.com")
{
MinimumSize = new Size(800, 600),
};

// 只用代码A是没问题的
/* 代码A
flowLayoutPanel.SuspendLayout();
b.Parent = this.flowLayoutPanel;
flowLayoutPanel.ResumeLayout();
* */

// 用代码B 却根本就加载不了浏览器
// 代码B,本意是要在等浏览器初始化完成后,再加入到父容器上
b.IsBrowserInitializedChanged += b_IsBrowserInitializedChanged;
}

void b_IsBrowserInitializedChanged(object sender, CefSharp.IsBrowserInitializedChangedEventArgs e)
{
var b = (ChromiumWebBrowser)sender;
flowLayoutPanel.SuspendLayout();
b.Parent = this.flowLayoutPanel;
flowLayoutPanel.ResumeLayout();
}
}
}
...全文
203 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧