tabbing with other keys

Using dbEdits, I want to have the enter key do the same thing that the tab key does.  I know how to trap the event of enter being pressed, but how do I tell it to do a tab?
danGynnAsked:
Who is Participating?
 
rwilson032697Connect With a Mentor Commented:
Ta!

Cheers,

Raymond.
0
 
RBertoraCommented:
what you want to do is send your control a tab message :

here I tab the dbgrid, but you can send
tab messages to any visual component

  sendmessage(DBgrid1.handle,wm_keydown,9,0);

Rob ;-)
0
 
RBertoraCommented:
hmm perhaps thats not what you want:

why don't you use something
like

dbedit1.onkeydown
  if (key = 10) or (key=13) then dbedit2.setfocus..

and so on for each dbedit box

Rob ;-)
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
danGynnAuthor Commented:
That didn't work.  It actually didn't seem to do anything.  Let me give you some more info.  I have a series of DBEdits each contained in their own panel.  I tried the sendmessage procedure with using both the edit handle and the panel handle.  Neither did anything.  Each of the DBEdit's has a tab order of 0 and the panels have the real tab order.  It works correctly if I actually use the tab key, and it executes send message when I hit the enter key, but the cursor does not move.
0
 
danGynnAuthor Commented:
The reason that I don't want to use setfocus for each edit is that there are a whole mess load of them, and I don't want to have to write an event handle for each of them telling them where their next tab should be to.
0
 
rwilson032697Commented:
Try this:

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    { move between each field by pressing the Enter Key }
    VK_RETURN : PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
  end;
end;

Cheers,

Raymond.
0
 
danGynnAuthor Commented:
rwilson, that did it!  If you submit an answer, I will give you the points.
0
All Courses

From novice to tech pro — start learning today.