using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.Security;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("www.google.com");
}
}
}
插入上面的代码后,我收到以下消息:当前的conext中不存在名称webBrowser1。 如何让webBrowser1工作?
答案 0 :(得分:3)
如果不实际将其添加到应用程序中,则无法访问Windows窗体控件。
转到表单的设计器视图,并确保在名为webBrowser1的表单中有一个Web浏览器控件。