hi
i m making a window application in C# .net.
can anyone tell me how can i use search engine in window application?

How do you intend to use the search engine?

Use an HttpWebClient and post form fields to search pages or figure out their URL structure and call it directly.

I'm pretty sure search engines will ban you for automating searches if the volume is large enough. <1000 queries a day shouldn't be a problem.

thanks 4 ur rply, but
i m making a window application not web application.
there is no connection to the web.
plz tell me answer with respect to a window application....

well i m making around 50 forms in my application, so for searching these forms i want to create a search engine in my window application...........
can u plz tell me how can i do this.....?

thanks 4 ur rply, but
i m making a window application not web application.
there is no connection to the web.
plz tell me answer with respect to a window application....

So, not in a web browser, but a file parser? And if I read your other post correctly, you want to parse .NET Forms? For what exactly?

yes i want to parse .net forms.
in my project there are around 50 forms, n i want to apply the search funtionality to search these forms. for example there are around 5 forms related to maths, 5 forms of physics content etc.
nw if a user enter any topic of maths in search option and if it is available in our application, it should display the link or button of that particular form and if not available than it should diplay the message"the particular form is not available".

What exactly are you wanting to search then? Do you have labels on the forms that you want to search for the word? Or .. ?

well let i have two maths form in my application which are related to factorization.......
so when i type factorization in search box, than the link related to both forms will be display to me, and when i click on anyone link , so that particular form will open

i think now my problem is clear to u

No, it isn't. You know that the forms are related to factoring -- but how does the search engine determine relevance? Programmatically how you can say "OK, this form is related to factoring, math, decimals, calculations, and division"

u r rite..........
well can u tell me one thing can i provide the search funtionality in .net window application like microsoft provide for windowXP? or not?

i mean is it possible to provide search funtionality for .net window application......?

Its not practical, no. You could use reflection and search for the literal string in all of your forms but it will be slow.

plz can u tell me how can i use reflection n search in my application, and from where i can know more more about these........?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;

namespace daniweb
{
  public static class FormSearcher
  {
    public static Type[] FindString(string Text)
    {
      List<Type> result = new List<Type>();
      Text = Text.ToUpper();
      foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
      {
        if (type.IsSubclassOf(typeof(Form)))
        {
          using (Form f = (Form)Activator.CreateInstance(type))
          {
            for (int i1 = 0; i1 < f.Controls.Count; i1++)
            {
              if (ContainsText(f.Controls[i1], Text))
              {
                result.Add(type);
                break;
              }
            }
          }
        }
      }
      return result.ToArray();
    }
    private static bool ContainsText(Control c, string Text)
    {
      if (c.Text.ToUpper().Contains(Text))
        return true;
      else
      {
        for (int i1 = 0; i1 < c.Controls.Count; i1++)
        {
          if (ContainsText(c.Controls[i1], Text))
            return true;
        }
      }
      return false;
    }
  }
}

Calling it:

private void button1_Click(object sender, EventArgs e)
    {
      Type[] list = FormSearcher.FindString("a");
      System.Diagnostics.Debugger.Break();
    }

This limits the searching to Form's but you could really use any container class in your application.

how can i make a container class in this,,?
and can i make a search option 4 my whole application? if yes than how?
and can u plz refer me any gud ebooks related to this, so that i can read in detail about this?

A form is a container class.... The code I posted searches all forms. Isn't that what you wanted?

After you find the forms what do you want to do? Show a message box with their names?

the code u posted is add on my 1st form, or i can use this on anyform?
well i just want to show the form after search

Zip your project and upload it. I'll show you a way to implement it

Actually... Here you go.

i m sending u sample application for search funtionality,
Also in my application on clicking on science node there appears two buttons, on clicking on buttons the form is opening sepratly.
how to open this form in the panel itself.............?

thanks 4 ur previous post.
but in your application all form open seperatly. the application i m sending u , in that i want that search form also will open or disply in center panel(panel2)............

I see that. I am making the modifications.. give me a few minutes :)

I hope you take the time to hit the solved button on this thread when I am done :P I spent a lot of time on it but its very neat code, I have never done something like this before.

ya ofcourse..........
n thanks 4 ur help n support

Here you go.

All of the code I changed or added is marked with "//sk" so search for that term in your project.

well i could not find the search button on the main form of my application..........
i want search button on main form, and when i click on that search button, so related form will display in center panel(panel2).................

Its under "Edit -- Find"

thanku very much...........

well can u tell me one more thing related to this..
let i made a list box on a form containig some text..
now when i click on save and print in menu strip n tool strip, so the data related to listbox will automatically save n print.....
and also if i want to perform all the option display in menu n toolstrip on my form, so how can i do that.................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.