Topic: Automatically setting focus on a text edit box

I have a series of edit boxes and what I would like to do is as I press  the 'enter' key, the next edit box automatically gets focus. So basically using the enter key instead of a tab key.


I'm wondering of there is an easier way than producing multiple 'ONKEYxxxx' events for each edit box.


I'm using a panel and page control on a form, so making the forms' KeyPreview := true and then


if key=#13 then
perform(wm_nextDlgCtrl,0,0);
end;

doesn't work.

On a clear disk you can seek forever

Re: Automatically setting focus on a text edit box

Hi CDB,
Perhaps try it like this (note that key preview needs to be set (see screenshot in the attachment).
Derek.

Post's attachments

Attachment icon enterkey.zip 483.05 kb, 272 downloads since 2020-04-29 

Re: Automatically setting focus on a text edit box

I shall go and try that immediately - thanks Derek.

On a clear disk you can seek forever