.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Windows Application >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Google Search from Windows Application

Posted By:Nikhil Kumar       Posted Date: January 19, 2010    Points: 25    Category: Windows Application    URL: http://www.dotnetspark.com  

Here is a tool developed in C# Windows Application which allows you to search on google based on your query which you give in textbox
 

Google Search from Windows Application:

Here is a tool developed in C# Windows Application which allows you to search on google
based on your query which you give in textbox.
The layout of this tool is :



Coding:

The coding is almost simple

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SearchTool
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }

  private void button1_Click(object sender, EventArgs e)
  {
  if (queryBox.Text.Trim().Length==0)
  {
  label1.Text = "Please enter text to search";
  return;
  }
  else
  {
  string nikhilkumar = "http://www.google.com/search?q=" + queryBox.Text;
  webBrowser1.Navigate(nikhilkumar);
  }
  }

  private void button2_Click(object sender, EventArgs e)
  {
  webBrowser1.GoBack();
  }

  private void button3_Click(object sender, EventArgs e)
  {
  webBrowser1.GoForward();
  
  }

  private void button4_Click(object sender, EventArgs e)
  {
  webBrowser1.GoSearch();
  }
  }
}


VB.NET

 

Imports System 
Imports System.Collections.Generic 
Imports System.ComponentModel 
Imports System.Data 
Imports System.Drawing 
Imports System.Text 
Imports System.Windows.Forms 
Imports System.IO 

Namespace SearchTool 
    Public Partial Class Form1 
        Inherits Form 
        Public Sub New() 
            InitializeComponent() 
        End Sub 
        
        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) 
            If queryBox.Text.Trim().Length = 0 Then 
                label1.Text = "Please enter text to search" 
                Exit Sub 
            Else 
                Dim nikhilkumar As String = "http://www.google.com/search?q=" & queryBox.Text 
                webBrowser1.Navigate(nikhilkumar) 
            End If 
        End Sub 
        
        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) 
            webBrowser1.GoBack() 
        End Sub 
        
        Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs) 
                
            webBrowser1.GoForward() 
        End Sub 
        
        Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs) 
            webBrowser1.GoSearch() 
        End Sub 
    End Class 
End Namespace
Here when you enter any word in Textbox and click on the Search Button the result will come in the
WebBroswerControl based on the query which you enter in the textbox
Back and Forward Buttons are used used to back and forward you search

Thanks !
 Subscribe to Articles

     

Further Readings:

Responses
Author: sridar1         Company URL: http://www.dotnetspark.com
Posted Date: April 06, 2011

In this project how can i use web browser

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend