【发布时间】:2017-02-23 22:46:57
【问题描述】:
所以这是我的设置,因此您可以更好地了解我想要做什么。我有以下内容: Windows 窗体 1(工具箱),带有一个用于 Google 搜索的文本框和一个用于加载辅助 Windows 窗体(搜索引擎)的“搜索单击”按钮。我想做以下事情。
- 在我的文本框中输入搜索条件并单击“搜索”按钮,该按钮将打开辅助 Windows 窗体(搜索引擎),该窗体将使用“WebBrowser1”在(搜索引擎)窗体上加载 google 搜索
任何帮助将不胜感激。如果您可以提供代码而不是去哪里最好:)
更新的代码:打开 Google 搜索引擎但不显示在 Webbrowser1 上。任何额外的帮助将不胜感激
Form 1 搜索按钮点击代码:
namespace Plumchoice_Toolbox
{
public partial class plumchoice_Form1 : Form
{
public plumchoice_Form1()
{
InitializeComponent();
}
private void plumchoice_Form1_Load(object sender, EventArgs e)
{
}
//Search Engine Form 1 added
//// Search Button that opens the Search Engine
private void button18_Click(object sender, EventArgs e)
{
Google_Search.SearchEngineForm1 frm2 = new Google_Search.SearchEngineForm1();
frm2.searchAddress = "http://www.google.com/webhp?hl=en&tab=ww#hl=en&tbo=d&output=search&sclient=psy-ab&q=" + textBox3.Text.Replace(" ", "+");
frm2.Show();
}
Webbrowser1 代码
namespace Google_Search
{
public partial class SearchEngineForm1 : Form
{
public SearchEngineForm1()
{
InitializeComponent();
}
public string searchAddress;
private void PlumChoiceToolboxForm1_Load(object sender, EventArgs e)
{
webBrowser1.Url = new Uri(searchAddress);
}
【问题讨论】: