In this quick tutorial we will learn how to search rows and columns in Listbox Control available in REALbasic. You will also find here a tip to execute search after pressing Enter key from keyboard. Watch it, learn it, enjoy it!
We will use in this tutorial Listbox Control, TextField Control and PushButton Control. Drag and drop this controls on Window1 Class wherever you like and fill Listbox with some data. If you have no idea what data can you insert there use this code in Listbox1 Sub Open ().
1 2 | Listbox1.ColumnCount = 2 Listbox1.InitialValue = "United Nations Day" + chr(9) + "UFC 104" + EndOfLine + "Halloween Costumes" + chr(9) + "Garth Brooks" + EndOfLine + "Los Angeles Angels" + chr(9) + "Hilary Swank" // chr(9) = Tab key |
Ok, in this moment we will search in Listbox all data (irrespective of number of rows and columns) to find our words for search. Add to PushButton1 Sub Open () some code… Please have in mind that our search code can return more than one result.
1 2 3 4 5 6 7 8 9 10 11 | Dim i, c As Integer for i = 0 to ListBox1.ListCount -1 for c = 0 to ListBox1.ColumnCount - 1 if InStr(ListBox1.Cell(i,c), TextField1.Text) < > 0 then // different from 0 ListBox1.CellBold(i,c) = true // make the text bold else ListBox1.CellBold(i,c) = false end if next next |
To know if the users is pressing the Enter key in TextField go to code editor TextField Function Key Down () and enter there:
1 2 3 | if key = chr(13) then // code from Search Listbox Control end if |
hi Jacob,
i started with realbasic a while ago and everytime i stop doing it again because i dont find a good place to learn but here i see you update regulary so now i start doing it untill i learn all.
do you have something like icq or so, so i can add you to my list in case i have questions?
i realy are motivated to learn it now
REGARD MARCEL
Hello Marcel,
nice to hear that you are now motivated to learn REALbasic
The best way to contact me is by email or Skype (login is the same like me email).
i try to find your email since i wrote to you but i still can find you on skype,please send me it by email to contact me on mmeuldijk on skype.
greetings marcel
btw keep up the good job so maybe in the future i can help out more here if i know more.
Done
is textfield is equal with editfield.??
I have older version of RB. Thanks
Yes, this is the same control.
Can you post the project? I tried this, but is not working for me.. I get nada… Thanks!
Hello,
ok, I will add this project tomorrow if this is no problem
Regards
Jakub
The file send you on mail and tutorial fixed
Your Paypal page comes up in Polish – I need to see an English page if I am to use it.
Hello chrisjk,
I don’t know why this page is now in Polish. You must enter there you email and password and then click Zaloguj sie (login) to go to the payment page.
hello chrisjk, changed to english version