Solved

searching

Posted on 1997-03-13
1
161 Views
Last Modified: 2010-04-04
In a form there are TQuery, TDatasource, TDBGrid and TEdit.
TEdit is for inputing SQL string. The records will be searched whenever the string in the TEdit changed. That is fine.

However, I would this application works in such a way:
when the user types (changes) the SQL string in the TEdit very quickly no searching happend until the user stop or slow typing (like the way in Windows95 for searching items in HELP).
0
Comment
Question by:zhuhail
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
ID: 1334853
Add a TTimer to your form, set its interval to e.g. 200 ms.

In the Edit's OnChange event, do as follows:

Timer1.Enabled := FALSE;  // Stop countdown if running
Timer1.Enabled := TRUE;  // Restart countdown from specified interval

In the Timer1.OnTimer event, do as follows

procedure TForm1.Timer1Timer(Sender : TObject);
const
  InProc : BOOLEAN = FALSE;
begin
  if InProc then exit;
  InProc := TRUE;
  Timer1.Enabled := FALSE;
  try
    // Do the query
  finally
    InProc := FALSE;
  end;
end;


Now, the query will run if the user don't type for 200 ms.


0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Check Delphi Seattle IOS app without MAC ? 1 105
code issue 8 156
Wincontrol not (correctly) drawn 15 42
enhance the following code 3 37
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question