Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

searching

Posted on 1997-03-13
1
Medium Priority
?
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Loops Section Overview
Suggested Courses

610 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