Announcement

Collapse
No announcement yet.

How to populate a ListBox content

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to populate a ListBox content

    1. Pls. How do I make a ListBox to populate its content (match words), as I type it in the input field.

    2. And when click a match it it should display in a paragraph text,

    3. also when I clear the input with a button, the ListBox should return to its initial state.


    I'm actually working on glossary project and has achieved everything except for question (1) and (3) above.

    Pls. Help with example I u can. Thanks.

  • #2
    What are you matching the text of the input against? Do you search a text file with a word list, or a database, or...?

    Ulrich

    Comment


    • #3
      Hi Ulrich, I'm happy ur d person attending to me. Let me outline my question better.

      1. How do I populate a word list from a database as I try to type a similar word in a search box (input field)

      2. And when I clear the typed word in the search box (input field). The ListBox should return to its initial state.

      Note. Pls think of any dictionary, maybe oxford. When you search for "Dog" you will find related alphabetical order in the list box. Infact, as you attempt to type the word, you will see the list populating with related match word. I want something similar to that.

      Comment


      • #4
        The Input object has a "On Key" event. You can use this event to run a script which checks the current content of the Input control. For example, if the Input is empty, you could clear the ListBox, and when at least two or three letters were provided, you could run a query to retrieve these items from the database where this substring can be found. Each item found would be added to the ListBox. When you continue typing, providing more data in the Input, you would run the query again, empty the current content of the ListBox, before adding the records matching the new filter.

        Reading the content of the Input, clearing and adding items to the ListBox should not offer any difficulty. The only problem you may have is when you run your query. You would need to construct a query which returns the field(s) you want, based on a substring. For example:
        Code:
        SELECT column FROM table WHERE column LIKE '%search%' ORDER BY column
        A query like this could return one or more results, and you would use a loop to insert all results into the ListBox.

        Ulrich

        Comment


        • #5
          I found the time to build a small sample application. You will need the Unicode plugin for this, as I am using part of Microsoft's Northwind sample database (which I imported into a SQLite3 database), and it features data with Unicode encoding.

          If you have the Unicode plugin installed, then simply open the project, preview/run it, and type a few letters into the filter Input. You will see the matching data in the ListBox, and as you type more, less records will be displayed in the ListBox.

          Ulrich
          Attached Files

          Comment


          • #6
            Thanks let me give it try

            Comment

            Working...
            X