how do I move to a control on delphi form

setfocus
howdiam1Asked:
Who is Participating?
 
Marco GasiFreelancerCommented:
Maybe you could use some more words, but if you want give focus to a control, as you said, you have to use SetFocus:
Button1.SetFocus;
Edit1.SetFocus;

Open in new window

If you want to know something else, I don't understan what it could be...
0
 
Sinisa VukCommented:
sometimes is good to check if focus is available:
if btn.CanFocus then btn.SetFocus;

Open in new window

0
 
Geert GOracle dbaCommented:
better is this :
ActiveControl := your_control;

it'll try to move the focus ... if not, nothing happens.

you can even set this in the form properties.
the control you set in that property will be the active control when the form is shown

be aware that it should be a component which can receive focus.
usually a descendant of TControl
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.