Board index » delphi » Lookup as you type

Lookup as you type

Hi

I am looking for a DBEdit field that does a lookup as you type in all the
datasets of that specific field (like in EXCEL).

Example: The filed firstname contains: 'John', 'Tom', 'Jane', 'Michael'.
If I type a 'M' in the Edit field it should be suggest imideatly 'Michael'.
If I type a 'J' it should either wait for the second character of sugest
'Jane' because she is first in alphabet. After adding a 'o' it should
suggest 'John'

Is there a component that does such a thing? Or a algorithm to do it
myself?

Answers very much apprichiated?

Andreas

E-Mail: come...@icon.co.za

 

Re:Lookup as you type


Youll probably have to code this your self using the filter

Christian Outreach Media <come...@icon.co.za> wrote in article
<01bc22d6$56de82a0$01dc1...@comedia.icon.co.za>...

Quote
> Hi

> I am looking for a DBEdit field that does a lookup as you type in all the
> datasets of that specific field (like in EXCEL).

> Example: The filed firstname contains: 'John', 'Tom', 'Jane', 'Michael'.
> If I type a 'M' in the Edit field it should be suggest imideatly
'Michael'.
> If I type a 'J' it should either wait for the second character of sugest
> 'Jane' because she is first in alphabet. After adding a 'o' it should
> suggest 'John'

> Is there a component that does such a thing? Or a algorithm to do it
> myself?

> Answers very much apprichiated?

> Andreas

> E-Mail: come...@icon.co.za

Re:Lookup as you type


Christian Outreach Media <come...@icon.co.za> wrote in article
<01bc22d6$56de82a0$01dc1...@comedia.icon.co.za>...

Quote
> Hi

> I am looking for a DBEdit field that does a lookup as you type in all the
> datasets of that specific field (like in EXCEL).

> Example: The filed firstname contains: 'John', 'Tom', 'Jane', 'Michael'.
> If I type a 'M' in the Edit field it should be suggest imideatly
'Michael'.
> If I type a 'J' it should either wait for the second character of sugest
> 'Jane' because she is first in alphabet. After adding a 'o' it should
> suggest 'John'

> Is there a component that does such a thing? Or a algorithm to do it
> myself?

> Answers very much apprichiated?

> Andreas

> E-Mail: come...@icon.co.za

Yes,  there are add on components that you can buy to perform these types
of tasks.
InfoPower is one of them.  I think that a demo even came with your delphi
cd.
To code it would be quite involved.

Cia

Re:Lookup as you type


Very simple solution: In the OnChange event for the field you do a findNearest on the underlying table.  Variations on this depending on the specifics - whether you want the suggestions in a drop down or displayed in a grid, whatever, but the basic idea is the the findNearest.

Quote
In article <01bc2331$a96db440$662470c2@ws037591>, "Nick Mappin" <map...@dircon.co.uk> writes:
>Youll probably have to code this your self using the filter

>Christian Outreach Media <come...@icon.co.za> wrote in article
><01bc22d6$56de82a0$01dc1...@comedia.icon.co.za>...
>> Hi

>> I am looking for a DBEdit field that does a lookup as you type in all the
>> datasets of that specific field (like in EXCEL).

>> Example: The filed firstname contains: 'John', 'Tom', 'Jane', 'Michael'.
>> If I type a 'M' in the Edit field it should be suggest imideatly
>'Michael'.
>> If I type a 'J' it should either wait for the second character of sugest
>> 'Jane' because she is first in alphabet. After adding a 'o' it should
>> suggest 'John'

>> Is there a component that does such a thing? Or a algorithm to do it
>> myself?

>> Answers very much apprichiated?

>> Andreas

>> E-Mail: come...@icon.co.za

Re:Lookup as you type


Here's some code I wrote just two days ago to meet a similar need. It
compares the text being entered in a TEdit with values contained in a
Listbox. As letters are typed, the Lisbox value with the closest match
in positioned at the top of the box. A very similar non-visual
approach can be taken with a DBEdit and database values:

procedure TMapIntersectionForm.Edit1Change(Sender: TObject);
var
  q : integer;
  TestStreet,EnterStreet : string[20];
begin
  for q := 0 to ListBox1.Items.Count-1 do
  begin
    TestStreet := copy(ListBox1.Items[q],1,Length(Edit1.Text));
    EnterStreet := Edit1.Text;
    if LowerCase(EnterStreet) = LowerCase(TestStreet) then
    begin
      ListBox1.TopIndex := q;
      Break;
    end;
  end;
end;

Mark Shapiro
info...@swbell.net

Re:Lookup as you type


This is all that I do.  Just move the pointer int he table with every
change to the TEdit.Text.

        procedure TForm.EditChange(Sender: TObject);
        begin
          Table.SetKey;
          TableField.Value := Edit.Text;
          Table.GotoKey;
        end;

Seems to work good enough for my apps so far.

howle...@bellatlantic.net

Re:Lookup as you type


In article <01bc22d6$56de82a0$01dc1...@comedia.icon.co.za>,
come...@icon.co.za says...

Quote
> I am looking for a DBEdit field that does a lookup as you type in all the
> datasets of that specific field (like in EXCEL).

  I've developed a component (TDBQuickFillEdit) that does what you want.  
The beta version of the 32 bit component is available at:

        http://www.ualberta.ca/~dcronin/Delphi.html

  Please note that this component IS STILL BETA and has not been
extensively tested by others.  All comments are welcome.  If there are any
problems please let me know.

---
David Cronin
http://www.ualberta.ca/~dcronin

Other Threads