|
|
|
Delphi - Using and Creating Lookups (1)
In this article we will cover how to create and use lookup forms in your Delphi (5) applications. For our examples we assume you already know how to read data from a data source and display the results in a data grid.
In today's times Lookup forms are ideal for applications that need a compact and tidy way to present the user with a search & selection type screen. A simple example is the Windows 'Open File' dialog box which pops up in front of the current screen and remains 'on top' until a file is selected or the dialog is closed.
In Delphi you too have the option to use the standard Windows dialogs such as PageSetup dialog, OpenFile dialog etc.. In this article we are going to create our own type of dialog which we refer to as a 'Lookup form'. A common situation for a Lookup is if you want your users to perform a database search to find a specific Customer and then return the selected customer details to the calling form. This is just an example and there are many, many ways you can use Lookup forms to create modern applications using Delphi.
Right, now lets look at how we create the lookup form. Don't be confused by the name a Lookup form is created in just the same way you would usually create a Delphi form by selecting File - New Form. However to make the lookup form 'stay on top' we must set its FormStyle property to StayOnTop. This will mean when we open the form in our application the Lookup will remain in focus until either the user selects a value or chooses to close the screen and cancel the selection.
So what does a typical lookup form contain? This question depends greatly on what you are trying to achieve with the popup. A good example of a Lookup screen is a Customer selection screen. The user is presented with a simple edit box to type in the customers name they want to search for, and below we present them with a data grid control to display the results of their search (we recommend dxDBGrid as the ideal data grid for Delphi). Once the user has selected the desired customer in the data grid, they then click the 'Select' button at the bottom of the screen to close the Lookup. Take a look at the screen shot below to get an idea behind the design of a simple Lookup:

|
|
Featured |
Other popular Delphi resources. Why not try them for yourself?
|
|
Delphi Knowledge Base. Best practices, walkthroughs, tutorials, component advice and more. Solutions and professional designs for Delphi 4, Delphi 5, Delphi 6 and Delphi, 7. Word COM, Excel COM, Outlook COM including code examples for Word OLE, Excel OLE and Outlook OLE. Automating Outlook to create MailItem and send attachments in Delphi. ActiveX, Com. ADO Data Architecture, TMS component pack walk through and code examples. Using Developer Express and example walkthroughs. Date & time conversion routines, video playback and frame manipulation. COM articles, papers, tips, techniques and hints. How to create Word reports and excel spreadsheets using Delphi code and OLE automation. Understanding Delphi encryption and using ciphers, with source code examples of Blowfish, Twofish, and Rijndael. Securing application data and confidential information using open source encryption components. Free encryption dll component. Accessing and managing MS Excel sheets with Delphi. How to retrieve, display and edit Microsoft Excel spreadsheets with Delphi automation. Accessing and managing MS Word documents with Delphi. How to retrieve, display and edit Microsoft Word documents using Delphi automation. Read and write Excel spreadsheets using Delphi code. How to read and write registry entries using Delphi code. Source code examples using Delphi 5, Delphi 6 and Delphi 7. Working with VCL Developer Express components. How to apply grid styles and themes to Delphi applications. Using image columns and shading to improve the grid and treeview appearances. Including examples from ExpressQuantumPack, for Delphi, ExpressPack for Delphi. Developer guides for Developer Express components. All our articles are written by our senior Delphi professionals to help you get the best from your legacy Delphi applications |
|