i'm trying to create a search bar where the user searches for an item.

the items are in ArrayList and there is multiple ArrayLists.

I want the user to be able to search for something, from all the available ArrayLists and show the result possibly in another listBox..

ie. user searches for documents,

search returns with all items containing documents which shows in listbox. then the user can click and open that object..

what is the best way to achieve this?

thanks.

Can you show us some of your code? What type are those array lists? Of custom objects (classes) or some general type, lile string or integer?

Anyway, put then into one collection, and then do a loop through this collection. And try to find what you are looking for.

To create a collection you can use a generic list <T>, where T is array list:
List<ArrayList> arraysCollection = new List<ArrayList>();
list.Add(arrList1);
list.Add(arrList2);
//and so on, you can use AddRange method instead of Add too.

Then do the looping:
string keyWord = "something";
foreach(ArrayList list in arraysCollection)
{
    foreach(YourArrayType item in list) //YourArrayType is custom class, string ot int,...
    {
         if(keyWord == item)
         {
               //item found!!
         }
    }
}

This is only an example how to do the search, since I have no more info, I can do no more (so far).

ArrayList stat = new ArrayList(); //stationary items
            stat.Add(new ListBoxItem("Corporate Letter Head", "1"));
            stat.Add(new ListBoxItem("Corporate Letter Head Follow on Typing guide", "2"));
            stat.Add(new ListBoxItem("With Compliments Slip", "3"));
            stat.Add(new ListBoxItem("Business Cards", "4"));
            stat.Add(new ListBoxItem("Business Cards Typgin Guide", "5"));
            stat.Add(new ListBoxItem("Corporate Presentation Folder - Cover", "6"));
            stat.Add(new ListBoxItem("Corporate Presentation Folder - Inner", "7"));
            stat.Add(new ListBoxItem("A4 Presentation Cover", "8"));
            stat.Add(new ListBoxItem("DL Envelope", "9"));
            stat.Add(new ListBoxItem("C4 Envelope", "10"));

and then once a specific button is pressed, data source is assigned

b2menu.DataSource = stat;

i'll mess around with your code, i should be able to get it to work, i didnt know about putting the arraylists' into a collection, and then searching that.. makes it much more simple.

thanks for your reply.
i'll have a go, and re post.

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.