If (TextBox1.Text <> Bookmarks.ListView1.Items) Then
            NoResultsFound.Show()
        End If

I want to display another class when the user's results dont match anything from the list. Help would be really appreciated. Thanks.

^The code above gave me this error:

Overload resoluton failed because no accessible '<>' can be called with these arguments. ...

Recommended Answers

All 5 Replies

The first term is of type String, the second is not. You have to select a specific item and subitem in the collection. You probably want to search like this.

Dim found As Boolean = False

For Each item As ListViewItem In Bookmarks.ListView1.Items
    If item.SubItems(0).Text = txtName.Text Then
        found = True
        item.Selected = True
        Exit For
    End If    
Next

If found Then
    'do something with selected item
Else
    NoResultsFound.Show()
End If

Thanks, but how do I display only the results.
I'm new to VB.NET, I'm more familiar with Java Syntax.

You'll have to be more specific.

  • What does the listview look like?
  • Can you get more than one match?
  • What exactly do you want to display?
  • How do you want to display it?
  • What do you mean?
  • Yes?
  • The results obtained?
  • All of the results beside each other.

You can create a second listview, lvwResults, that is identical in format to Bookmarks.ListView1 and display the matches as follows

lvwResults.Items.Clear()

For Each item As ListViewItem In Bookmarks.ListView1.Items
    If item.SubItems(0).Text = txtName.Text Then
        lvwResults.Items.Add(item.Clone)
    End If
Next
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.