Solved

searching

Posted on 1997-03-13
1
157 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now