任何人都可以查看我的代码,我不会完全听懂有关错误的信息
private void InitializeComponent()
{
this.WebBrowserHost = new System.Windows.Forms.Integration.ElementHost();
this.SuspendLayout();
//
// WebBrowserHost
//
this.WebBrowserHost.Dock = System.Windows.Forms.DockStyle.Fill;
this.WebBrowserHost.Location = new System.Drawing.Point(0, 0);
this.WebBrowserHost.MinimumSize = new System.Drawing.Size(20, 20);
this.WebBrowserHost.Name = "WebBrowserHost";
this.WebBrowserHost.Size = new System.Drawing.Size(284, 262);
this.WebBrowserHost.TabIndex = 0;
//
// AuthorizationWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.WebBrowserHost);
this.Name = "AuthorizationWindow";
this.Text = "AuthorizationWindow";
this.ResumeLayout(false);
}
在我的表单中,我只有一个WebBrowser
控件,我遇到错误:
无法隐式转换类型 ' System.Windows.Forms.Integration.ElementHost'至 ' System.Windows.Forms.WebBrowser'
初始化后我需要像这样的ElementHost.Child
public AuthorizationWindow()
{
// This call is required by the designer.
InitializeComponent();
WebBrowser = new System.Windows.Controls.WebBrowser();
WebBrowserHost.Child = WebBrowser;
WebBrowser.Navigating += WebBrowser_Navigating;
WebBrowser.LoadCompleted += WebBrowser_LoadCompleted;
_authorization = new AuthorizationState();
}
答案 0 :(得分:0)
您是否尝试更改该行
this.WebBrowserHost = new System.Windows.Forms.Integration.ElementHost();
到
this.WebBrowserHost = new System.Windows.Forms.WebBrowser();