它会跳过导航到有效网址并直接进入Google搜索.如果我在文本框中输入"stackoverflow.com",谷歌将搜索"stackoverflow.com".
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(textBox1.Text); //navigates to url in textbox
if (!textBox1.Text.StartsWith("http://"))
{
webBrowser1.Navigate("http://www.google.ie/search?q=" + (textBox1.Text));
}
}
Run Code Online (Sandbox Code Playgroud)