Text Fields in XOJO

Is it possible to implement something like this Xojo?


Sure!

Why not just use a drop down list / pop up menu.

Not clear on exactly what it is you want to do, but have a look at the Formatted Text Control from BKeeney Software

How would that help???

I’m curious as well. :slight_smile:

My guess is that OP wants something like a combobox where you can start typing and the drop down automatically change and narrow the options to what is in the box.

I seem to recall someone had one here on the forum as open source …

It is relatively easy to code such restrictions when the process is well defined. Based on the first selection, query a database and fill the second combobox, and so on. The code to fill the second combo box is in a method called by the selection changed event of the first combobox. With an in-memory database, the time lag is minimal. I use this approach in a few applications.

The ComboBox has an autocomplete property, so that is what I would use.

P.S. Have a read through this thread https://forum.xojo.com/21935-combobox-and-restrict-entry/0

I did this exact thing with a ListBox with a TextField above it. As the user types in the TextField, the LB is repopulated based on the text in the text field. It did perform a SQL Select based on the selection but it was so fast as to not see a delay on a desktop app.

I have reused this several times…

TextField + ListBox. Simple.

[quote=382374:@Bill Plunkett]I did this exact thing with a ListBox with a TextField above it. As the user types in the TextField, the LB is repopulated based on the text in the text field. It did perform a SQL Select based on the selection but it was so fast as to not see a delay on a desktop app.

I have reused this several times…[/quote]

Got some code to share? And yes, I can write it myself, I‘m just feeling smart (it’s not lazy if you don’t want to do duplicate work!) …

This code is executed on the KeyUp event of the the TextField. I pass in a trimmed string from the TextField and use it in the select. LBMembers is the list box that is updated…

[code]Private Sub LoadRSsearch(sStart As String)
dim i As Integer
dim sSQL As String
dim sMsg As String
Dim sFilter As String

sFilter = sStart + “%”

sSQL = “SELECT * FROM Members WHERE LastName LIKE '” + sFilter + “’ ORDER By LastName”

rsMembers = dbSQL.SQLSelect(sSQL)
if dbSQL.Error then
sMsg = "DATABASE ERROR Reading Members Table, Error: " + dbSQL.ErrorMessage
MsgBox(sMsg)
UpdateLog(CurrentMethodName, sMsg, “E”)
Quit
end if
if rsMembers = nil then
sMsg = “No records found on Retrieval”
MsgBox(sMsg)
UpdateLog(CurrentMethodName, sMsg, “E”)
Return
end if

PopulateMembersLB(0)

Return

End Sub
[/code]

[code]Private Sub PopulateMembersLB(iRecToSelect As Integer)
dim i As Integer
dim sFirstName As String
dim sGoesBy As String
dim sLastName As String
dim sName As String
dim sSQL As String
dim sMsg As String
dim sMode As String
dim sFilter As String
dim iSelectRow As Integer
dim iCurrentKey As Integer

if bFiltered then
sFilter = “Custom Filter”
else
sFilter = “None”
end if

lblRecords.Text = "Members Displayed: " + str(rsMembers.RecordCount )
lblFilter.Text = " Filter: " + sFilter
rsMembers.MoveFirst

lbMembers.deleteAllRows

i = 0
while not rsMembers.eof

ICurrentRecord = rsMembers.Field("pkRecID").IntegerValue
iCurrentKey    = ICurrentRecord
sFirstName     = rsMembers.Field("FirstName").StringValue
sGoesBy        = rsMembers.Field("GoesBy").StringValue
if sFirstName <> sGoesBy then
  sFirstName = rsMembers.Field("FirstName").StringValue + "  '" + sGoesBy + "'" 
end if
sLastName      = rsMembers.Field("LastName").StringValue
sName          = sLastName + ", " + sFirstName

lbMembers.addRow
lbMembers.RowTag(i)    =rsMembers.Field("fkMemberID").IntegerValue
lbMembers.cell( i, 0 ) = sName

if rsMembers.Field("pkRecID").IntegerValue = iRecToSelect then
  iSelectRow = i
end if

i = i + 1
rsMembers.MoveNext

wend

if iRecToSelect > 0 then
lbMembers.ScrollPosition = iSelectRow
lbMembers.selected(iSelectRow) = true
end if

Return
End Sub
[/code]

Either I do not saw that Property / Not read that entry / Not understand / Whatever: I never implemented it.

I just enabled that property, and it worked fine.

Unfortunately, something went wrong:the selected entry do not goes into the ROWTAG feature (the AutoCompleted Row is not the one who have a RowTag). So, useless as is.

To really implement something useful, I have to take the resulting text, then search the .Text Row, then go thru its .RowTag property (to have the Unique ID of the wanted RecordSet, etc.).

Yes, a bit strange.

I will read Bill shared Code, but I think I will set .AutoComplete back to False.

Even my current implementation is not Rock Solid (returns some MsgBox Errors if the entry is incomplete: nothing found in the DB). :frowning:

You don’t get a valid ListIndex value?

No, because the AutoCompleted text appears in the ComboBox’ Edit Row, not in its own entry (as far as I can understand).

I was curious to try that feature. Definitively do not works as a PopupMenu (no auto complete there, but you go to the real Row)…

Thanks Tim.