Windows应用程序对Google搜索的怀疑 [英] Doubts in Windows application for google search
本文介绍了Windows应用程序对Google搜索的怀疑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
海,
我正在开发Windows应用程序中的google搜索选项项目.在我的项目中我有一些疑问.以下是示例代码.我在"webbrowser"中遇到错误.
Hai,
I am developing a project for google search option in the windows application.In my project I am having some doubts.Below is the sample code. I am getting the error in "webbrowser".
"An object reference is required for the non-static field, method, or property ''System.Windows.Forms.WebBrowser.GoSearch()''".<br />
同样,我在WebBrowser.GoBack(),WebBrowser.GoForward(),WebBrowser.Navigate(string)
中遇到错误.
请对此进行纠正.
similarly i am getting error in WebBrowser.GoBack(),WebBrowser.GoForward(),WebBrowser.Navigate(string)
.
Please rectify this.
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.IO;
namespace WINDOWS_APPLICATION_GOOGLE_SEARCH
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length==0)
{
label1.Text = "Please enter text to search";
return;
}
else
{
string sridharan = "http://www.google.com/search?q=" + textBox1.Text;
WebBrowser.Navigate(sridharan);
}
}
private void button4_Click(object sender, EventArgs e)
{
WebBrowser.GoBack();
}
private void button3_Click(object sender, EventArgs e)
{
WebBrowser.GoForward();
}
private void button1_Click(object sender, EventArgs e)
{
WebBrowser.GoSearch();
}
}
}
推荐答案
我在您的代码中看不到WebBrowser
的实例.
有两种方法可以得到一个.
1)将Webrowser从工具箱拖到您的表单中
2)以编程方式进行
I can''t see an instance ofWebBrowser
in your code.
There a two ways to get one.
1) Drag Webrowser from toolbox to your form
2) do it programamtically
WebBrowser myBrowser = new WebBrowser();
myBrowser.Parent = myform; // or whereever you want to show it
//myBrowser.allTheOtherPropertiesIwantToSet...
// some more code
myBrowser.navigate("http://....");
我认为您错过了这段代码.对我来说很好.
I think you missed something in this code. It works good with me.
这篇关于Windows应用程序对Google搜索的怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文