Search Field in xojo


I have an issue with the searchfield in xojo. See PrintScreen:

I like made the searchfield on this window. The search field need to search the datas in the same listfield who I can change the adresses, etc.

I don’t find a tutorial for this

Thanks for your help.


add a method for the list search

Public Sub Search(tx as String)

  System.DebugLog CurrentMethodName
  Var lb As Listbox = Listbox1
  For row As Integer = 0 To lb.LastRowIndex
    Var found As Boolean = False
    For col As Integer = 0 To lb.ColumnCount-1
      Var s As String = lb.CellValueAt(row,col)
      If s.IndexOf(0, tx, ComparisonOptions.CaseInsensitive) >= 0 Then 'ok
        found = True
      End If
    lb.Selected(row) = found
End Sub

at pressed event

Sub Pressed() Handles Pressed
Search Me.Text
End Sub

the listbox need property multi select.
it will only select the rows, its not a filter.
you could search the data first and the rest of it you would put into the list.

Hi Thanks for your help.

Yet I become this error
Adressverwaltung.search_adressverwaltung.Pressed, line 7
Syntax error
End Sub

Das End Sub gehört nicht dazu, Xojo verwaltet die Methoden ein bischen ungewöhnlich :wink:

1 Like

Ich krieg aber die folgenden Fehler, wenn ich das rausnehme:

Adressverwaltung.search_adressverwaltung.Pressed, line 1
Syntax error
Sub Pressed() Handles Pressed

Adressverwaltung.search_adressverwaltung.Pressed, line 3
There is more than one method with this name but this does not match any of the available signatures.
Search me.Text

Adressverwaltung.Search, line 1
Syntax error
Public Sub Search(tx as String)

Public Sub Search(tx as String)
… code …
End Sub

mark the beginning and end of a subroutine, and are added automatically when you add a method in the IDE.

So you can either copy the complete code with the sub header and end Sub and paste it in the IDE, or add a method (which then has the default subheader), rename the method to Search, paste the parameter (here: tx as string) in the parameter field, and the code in the code field.

What you cannot do is leave bits out and expect it to work.

how it looks

Hi I do this 1:1 maybe I can’t search nothing with Enter.

See the following PrintScreens:

Thanks for your help.


Because your code isn’t doing anything.

It basically says

If foundSomething then
End if

What do you expect that to do???

1 Like

I like to do the following with the application:

The following situation:
I wrote a address database tool. I can set new addresses, delet addresses, etc.

I need for this the searchfield for search addresses.

Its a simple addresslist. I like only search for example “Müller” and then show me the address in the list.

Thats all.

Thanks for your feedback.

you did not used the row with fround = true in screenshot
this flag would select the row

Hi @Marcello_De_Matteo

Maybe you can look the “Eddies Electronics” example project under the Sample Applications folder. It makes use of the SearchField control to filter the contents of the ListBox.

From my experience in database searches - but not Xojo - it can be really tricky. The way you are describing it, it sounds like your “match” must match exactly and that is very difficult when it comes to addresses. There is usually an assumption of correct spelling in name, or address, or abbreviations. There is a algorithm/tool called SoundX that selects things that “sound” like another so you can find similar entries if their spelling is off a little. One downside with that tool is the first letter has to match. So, for example, it won’t pick up Kris and Chris. But it would pick up Cris and Chris.

One of the challenges in working with “real world” data is accepting and programming to accommodate data entry inconstancies.

Yes, this is very difficult.

I search a solution