This article was brought to you by the guys from VDF-GUIdance.
For more DataFlex targeted articles see http://www.vdf-guidance.com


AutoComplete

by David Martinko

Summary

*** UPDATE ***
Added support for Modal Panels. Changed a lot of logic dealing with positioning of the list. Removed list from view and located list directly into Main_Panel_ID (unless used within a modal panel, then it is a child of the modal panel). Changed logic for setting column lables to remove limitation of number of columns allowed. Finished up some more support for manually filling the list. Added some code to make sure the list is killed when changing tab pages.

More support for manually filling the list.
Directory browsing added to the samples.

Speed user entry. See results matching what you type. Choose an entry from the list to complete your entry, or use it to make that the active record.

No DLL's, no ActiveX controls, written completely with native dataflex code. A sample view is included for the Order Entry Sample Workspace so you can start testing it right away and have a sample on how to use it. Another great feature is that the same code works from vdf8 or higher without ANY co
Size: 46 KB Download
Date Created: 21/03/2004
Date Updated: 07/07/2005
Author: David Martinko
Company: Redeemed Software


Compatibility


VDF 11.1 tested and approved
also works with VDF 8.x, 9.x, 10.x

Definition


Welcome to one of my latest contributions! This is by far one of the best things I have the pleasure of sharing with the rest of the VDF Community.

What is does: Simply, it displays information from a datafile based on what you typed. For advanced users, the list can be filled manually.

How it works: It is connected to a datadictionary. When you stop typing, it will take what you have typed and search for any records that start with the same data in the field. Each record it finds that matches the constraints will then be displayed in the list. The user can then select a record from the list.

Why it is better than a comboform: You can tell it which fields to display. You can even choose fields from a parent file. It will use constraints you have placed in the DD. Fields will show using the Field_Masking defined by you in the DD. It popups up based on what you typed and is soooo fast!

Special features:
It will treat numeric fields like an ascii field for searching purposes (example: "43" would find any numeric value beginning with "43". The following numbers are valid finds "43, 431,432,43918".)
There is a delay from the last key pressed and when the list pops up. You can control this delay if you wish. There is a property for the maximum number of finds. This will abort the searching after the max number of matching finds has been done (helpful if the user searches for common data).
There is a property that will allow the user to find all data GT the entered value (example: "C" would find any values starting with "C" or a character GT 'C". The following values are valid finds "C, CA, DE, Z").
You can toggle the autocomplete option on/off as needed. This means you can customize on a per user basis, or allow/disallow it based on other criteria.
When an item is selected from the list, you have full control over what happens. I give you the method to retrieve the value of the selected record. This means you can make the record active in the buffer or default the value only.
Titles can be displayed for the columns in the list.
There is a property which controls how many records are found. Another property controls how many records are displayed at a time. If more records are found than you have chosen to display, a scrollbar will appear within the list. Users can pageup, pagedown, arrowup or arrowdown through the list.

Installation


We will describe here how-to install this package into the orderentry workspace
  • Copy the *.pkg files to the .\Order\AppSrc folder
  • Copy the *.df* and *.bmp files to the .\Order\IdeSrc folder
  • Open your IDE and go to the tools menu, select Maintain classlist
  • Select the workspace tabpage as we want to install this in one workspace for now
  • Click the Add button to open the "Open a New Class In The Current Workspace" dialog and enter the following details:
    1. Name: DBForm_AutoComplete
    1. Image: DBForm_AutoComplete.bmp
    1. Page : Data
    1. File: DBForm_AutoComplete
  • Click the ADD-button
  • Click Ok
    1. Name: DBGrid_AutoComplete
    1. Image: DBGrid_AutoComplete.bmp
    1. Page : Data
    1. File: DBGrid_AutoComplete
  • Click the ADD-button
  • Click Ok
    1. Name: Form_AutoComplete
    1. Image: Form_AutoComplete.bmp
    1. Page : Base
    1. File: Form_AutoComplete
  • Click the ADD-button
  • Click Ok

Usage


The DFO contains all the same code you should need. A sample view is also provided for the Order Entry Sample Workspace. Register the sample view and begin using the control immediately.

Just drag a new DBGrid_Autocomplete, DBForm_Autocomplete, or Form_Autocomplete onto your view and look at the code defaulted inside the object for you.

You must set the index to use.
You must add fields to the autocomplete.
You must augment the Procedure Accepted if you want something to happen when the user makes a selection. Beyond that, there is nothing else you need to do in order to get the sample working.

It only supports DF_BCD and DF_ASC field types. I didn't feel dates would be efficient and needed.

Minimum Requirements are VDF8.

Download



VDF Autocomplete ~ 46 kB