Board index » delphi » incremental search with dbgrid display

incremental search with dbgrid display

Is there a way to "send" a keystroke to a dbgrid programatically?
I am doing an incremental search in a text box that positions the
underlying dataset to the matching record in the grid.  I enable
keypreview to trap the up and down arrow keys which moves
the recordpointer to the next/previous records.  I could do the
same with pageup/pagedown if I could determine the number of
visible rows in the grid.  Any suggestions?

 

Re:incremental search with dbgrid display


Quote
>Is there a way to "send" a keystroke to a dbgrid programatically?
>I am doing an incremental search in a text box that positions the
>underlying dataset to the matching record in the grid.  I enable
>keypreview to trap the up and down arrow keys which moves
>the recordpointer to the next/previous records.  I could do the
>same with pageup/pagedown if I could determine the number of
>visible rows in the grid.  Any suggestions?

I put a edit box on the screen and when  attach a method like below to
the Change Event of the Edit Box.  You of course have to setup an
appropriate index for the table in question.

procedure TfrmMain.frmMainEnter(Sender: TObject);
begin
     edtSearch.Text := '';
     edtSearch.SetFocus;
     edtSearch.Hint := 'Enter Name for Search...';
end;

procedure TfrmMain.edtSearchChange(Sender: TObject);
begin
     if edtSearch.Text > '' then
        tblDonors.FindNearest([edtSearch.Text])
end;

Other Threads