[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

how do I move to a control on delphi form

setfocus
0
howdiam1
Asked:
howdiam1
3 Solutions
 
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 GruwezOracle 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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now