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
Next
lb.Selected(row) = found
Next
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.
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)
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.
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.