Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:21:23+00:00 2026-06-16T03:21:23+00:00

My goal is to develop a search using multiple textboxes. I have five columns

  • 0

My goal is to develop a search using multiple textboxes. I have five columns (ArticleNo, Description, PartNum, Manufacturer and Cost) each of which will have a textbox over them.


I keep track of the original list items using:

Private originalListItems As New List(Of ListViewItem)

This is filled with all the items (over 6000).

Then I will have five “text changed” events occuring based on the five textboxes created (tbSearchArticleNo, tbSearchDescription, tbSearchPartNum … etc)

Private Sub tbSearchArticleNo_TextChanged(sender As Object, e As System.EventArgs) Handles tbSearchArticleNo.TextChanged
    If tbSearchDesc.Text <> "" Or tbPartNum.Text <> "" Or tbManufacturer.Text <> "" Or tbCost.Text <> "" Then
        SearchCurrentList(lwArticles, tbSearchArticleNo.Text, 0, False)
    Else
        SearchListView(lwArticles, tbSearchArticleNo.Text, 0, False)
    End If
End Sub

Here is my method SearchCurrentList:

Private Sub SearchCurrentList(ByVal listview As ListView, ByVal search As String, ByVal colIndex As Integer, ByVal upperCase As Boolean)
    If upperCase Then
        search = search.ToUpper()
    End If

    listview.BeginUpdate()

    'Clear listview
    lwArticles.Items.Clear()

    'Other textbox has information in it, concatenate both results
    For Each item In currentListItems
        Dim itemToUpper = item.SubItems.Item(colIndex).Text
        If upperCase Then
            itemToUpper = item.SubItems.Item(colIndex).Text.ToUpper()
        End If
        If itemToUpper.Contains(search) Then
            lwArticles.Items.Add(item)
        End If
    Next

    'Reupdate the current list of items
    currentListItems.Clear()
    For Each item In lwArticles.Items
        currentListItems.Add(item)
    Next

    listview.EndUpdate()
End Sub

And here is my method SearchListView:

Private Sub SearchListView(ByVal listview As ListView, ByVal search As String, ByVal colIndex As Integer, ByVal upperCase As Boolean)
    'Upper case parameter determines if you're searching a string, if so, it is better to compare everything by uppercase
    If upperCase Then
        search = search.ToUpper()
    End If

    listview.BeginUpdate()

    If search.Trim().Length = 0 Then
        'Clear listview
        listview.Items.Clear()

        'Clear currentListItems
        currentListItems.Clear()

        'If nothing is in the textbox make all items appear
        For Each item In originalListItems
            listview.Items.Add(item)
        Next

    Else
        'Clear listview
        listview.Items.Clear()

        'Clear currentListItems
        currentListItems.Clear()

        'Go through each item in the original list and only add the ones which contain the search text
        For Each item In originalListItems
            Dim currItem = item.SubItems.Item(colIndex).Text
            If upperCase Then
                currItem = currItem.ToUpper()
            End If
            If currItem.Contains(search) Then
                currentListItems.Add(item)
                listview.Items.Add(item)
            End If
        Next
    End If

    listview.EndUpdate()
End Sub

Here’s an example of my search:

tbSearchArticleNo.Text = “33”

This will match every articleNo that contains “33” in the string. Now I want to add another filter:

tbSearchDescription.Text = “Mixer”

This should match everything that contains 33 in the article number as well as “mixer” in the description. And so on and so fourth.


The actual filters are working correctly – my only problem is whenever I erase something, such as “Mixer” (while still having “33” in the articleNo) it doesn’t return the results of the articleNo containing “33” … Instead it doesn’t change the results of my search. There might be a better way of searching through this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:21:24+00:00Added an answer on June 16, 2026 at 3:21 am

    A somewhat different way of handling this is to use LINQ. The following function could be used to return an object that enumerates the provided collection including only those items that fit the filter. You could use this enumerator to re-populate your list. If you used originalListItems each time you called GetFilter, you would always have every item included for consideration in the latest filter.

    Function GetFilter(source As IEnumerable(Of ListViewItem), articleNo As String, description As String,
                      partNum As String, prop4 As String, prop5 As String) As IQueryable(Of ListViewItem)
      GetFilter = source.AsQueryable
    
      Dim articleFilter As Expressions.Expression(Of Func(Of ListViewItem, Boolean)) = _
         Function(i As ListViewItem) i.SubItems(0).Text.IndexOf(articleNo, StringComparison.InvariantCultureIgnoreCase) >= 0
      Dim descFilter As Expressions.Expression(Of Func(Of ListViewItem, Boolean)) = _
         Function(i As ListViewItem) i.SubItems(1).Text.IndexOf(description, StringComparison.InvariantCultureIgnoreCase) >= 0
      Dim partFilter As Expressions.Expression(Of Func(Of ListViewItem, Boolean)) = _
         Function(i As ListViewItem) i.SubItems(2).Text.IndexOf(partNum, StringComparison.InvariantCultureIgnoreCase) >= 0
      Dim prop4Filter As Expressions.Expression(Of Func(Of ListViewItem, Boolean)) = _
         Function(i As ListViewItem) i.SubItems(3).Text.IndexOf(prop4, StringComparison.InvariantCultureIgnoreCase) >= 0
      Dim prop5Filter As Expressions.Expression(Of Func(Of ListViewItem, Boolean)) = _
         Function(i As ListViewItem) i.SubItems(4).Text.IndexOf(prop5, StringComparison.InvariantCultureIgnoreCase) >= 0
    
      If Not String.IsNullOrEmpty(articleNo) Then GetFilter = Queryable.Where(GetFilter, articleFilter)
      If Not String.IsNullOrEmpty(description) Then GetFilter = Queryable.Where(GetFilter, descFilter)
      If Not String.IsNullOrEmpty(partNum) Then GetFilter = Queryable.Where(GetFilter, partFilter)
      If Not String.IsNullOrEmpty(prop4) Then GetFilter = Queryable.Where(GetFilter, prop4Filter)
      If Not String.IsNullOrEmpty(prop5) Then GetFilter = Queryable.Where(GetFilter, prop5Filter)
    End Function
    

    Better yet, with a little more thought, you could probably make articleNo and the other parameters into variables with a larger scope, and adjust the function to embed IsNullOrEmpty checking into the Queryable expression, and then you wouldn’t need to even re-generate the filter when a field value changes. You could just set the variable to the new textbox value and re-evaluate the already-generated filter expression, which will consider the new values in the variables thus yielding newly filtered results.

    Here’s how I would expect it to be used:

    lwArticles.Items.Clear()
    For Each i In GetFilter(originalListItems, tbSearchArticleNo.Text, tbSearchDesc.Text, tbPartNum.Text, tbManufacturer.Text, tbCost.Text)
       lwArticles.Items.Add(i)
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Cloud9 IDE. My goal is to be able to develop applications that
I am using ASP.NET MVC to develop an application framework. Essentially, the end goal
my goal is to develop a signature generator for board-signatures. I have my database
We have a basic data entry app we want to develop using QT as
I've been dealing with this problem for my thesis. The goal is to develop
my goal is to track all logged users in my web portal to develop
I just started to develop a new module in Drupal. The goal of the
Goal: To develop a web based NMS interface which displays a network topology (e.g.,
I develop websites since last two years now and I have hard time learning
I'm using Eclipse to develop application for embedded systems. One of the options of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.