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 :

SearchTool.JPG

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

  1. Imports System
  2. Imports System.Collections.Generic
  3. Imports System.ComponentModel
  4. Imports System.Data
  5. Imports System.Drawing
  6. Imports System.Text
  7. Imports System.Windows.Forms
  8. Imports System.IO
  9.  
  10. Namespace SearchTool
  11.     Public Partial Class Form1
  12.         Inherits Form
  13.         Public Sub New()
  14.             InitializeComponent()
  15.         End Sub
  16.        
  17.         Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
  18.             If queryBox.Text.Trim().Length = 0 Then
  19.                 label1.Text = "Please enter text to search"
  20.                 Exit Sub
  21.             Else
  22.                 Dim nikhilkumar As String = "http://www.google.com/search?q=" & queryBox.Text
  23.                 webBrowser1.Navigate(nikhilkumar)
  24.             End If
  25.         End Sub
  26.        
  27.         Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
  28.             webBrowser1.GoBack()
  29.         End Sub
  30.        
  31.         Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)
  32.                
  33.             webBrowser1.GoForward()
  34.         End Sub
  35.        
  36.         Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
  37.             webBrowser1.GoSearch()
  38.         End Sub
  39.     End Class
  40. End Namespace

Here when you enter any word in Textbox and click on the Search Button the esult 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 J

Thanks !


Ebook Download
View all
Learn
View all