image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Articles
   3D
   Audio
   Custom Controls
   General RB
   Graphics
   Hacks
   Mac OS X
   Menus
   Novelty
   Printing
   REALbasic 2005
   REALbasic 2006
   Registration
   Resources
   Reviews
   Serial
   Speech
   Sockets
   XML
   Video
Resource Links
News
   Current News
   February 2006
   January 2006
   December 2005
   November 2005
   October 2005
   September 2005
   August 2005
   July 2005
   June 2005
   May 2005
   April 2005
   March 2005









REALbasic for Dummies
by Erick Tejkowski


Learning REALbasic through Applications
by Clayton E., Crooks II


REALbasic for Macintosh
by Michael Swaine


REALbasic Cross-Platform Application Development
by Mark S. Choate





Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander
Tell us about a bad link. Thank You!

Listbox Auto-Find by Erick Tejkowsi
12-05-02

Printer Version




When you use the REALbasic Listbox control, sometimes it's nice to offer an "auto-find" feature. As you press keys on the keyboard, the Listbox should attempt to locate any rows that display text that matches the pressed keys. The REALbasic Listbox doesn't perform this functionality, but it's not difficult to implement it yourself. This week we'll show you how.

Prep
capitals, states, currentkeys Launch REALbasic and open the Code Editor for the default window - Window1. Add three properties to the window by choosing Edit-New Property.

  • LocateState(state as string)
  • PopulateStates
  • PopulateCapitals
This project is a little US-centric, in that it displays the states and capitals of the UNited States. (Sorry, international readers!)

Build the Interface
To create the interface for this project, open Window1 and add a Listbox, a Timer, and a StaticText control. Set the Timer's Period to 2000 in the Properties Window. Then, rearrange the various controls in the window to look like this.

12-05-02_window.jpg (23k)

Add the Code
To set things up, add the following code to the Open event of Listbox1.

Listbox1.Open


Then, add the following code to the KeyDown event of the Listbox. This is where we track the keys that a users presses. As they press keys, we keep a running sequence of those keys. We also check to see if there is a match in the list using the LocateState method.

Listbox1.KeyDown


Next, add a little code to the Action event of Timer1. This resets the sequence of keypresses once every 2 seconds.

Timer1.Action


Finally, add the code for the three methods you created earlier. One method does the search for a match between keypresses and the Listbox contents. The other two methods populate the Listbox with state and capital names.

LocateState


Populate States


PopulateCapitals

Conclusion
That's it for this week. As usual, you can download the completed project instead of typing it in. See you next week!




Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]