Making an DBEdit field autoexit

Is it possible to make a DBEdit field to automatically exit to the next field (like pressing tab) as soon as it is totally filled? DBASE used to do that automatically.
avjAsked:
Who is Participating?
 
ptiemannConnect With a Mentor Commented:
yes, it is possible :-)
You have to write some eventhandler for the OnChange event. The following code exits to the next field when you have reached 12 characters.
You may derive your own component from TDBEdit that does this automatically so you don't have to code it for each control separately.

procedure TForm1.DBEdit1Change(Sender: TObject);
begin
  if length(DBEdit1.Text) = DBEdit1.Field.DataSize then
    PostMessage (Handle, WM_KEYDOWN, VK_TAB, 0);
end;

Note: Use PostMessage instead of SendMessage (which would not work)
0
 
itamarCommented:
I'm also interested in the other solution therefore I'll repost this question for 25 points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.