How to do a Setfocus on a Dynamically created visual component (Syntax)

Platform D7.

In this project, there are multiple controls dynamically created based on a the contents of a data set that defines them.  That part is all up and running.  As they are created, I set the TAG component and relate it to the DB definition so that I can go back and find the component.

I am using the search components[I] technique below to find the component.
Var TargetComponent: Integer;

        For I:=1 to ComponentCount -1 do
        Begin
          If Components[I].Tag = TargetComponent then
          Begin
            TargetComponentName:= Components[I].Name;
            Components[I]. xxxxx   .SetFocus;                        <================= Help here.          
          End;
        End;

Since components are not established at Design Time, working to locate, and then reference some of the components values, and get Focus set to that control based on another program event.   Having problems with the Syntax to get the .SETFOCUS part to work.  
LVL 1
chart11610Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ferruccio AccalaiConnect With a Mentor Senior developer, analyst and customer assistance Commented:
If Components[i] is TwinControl then
   TwinControl(Components[i]).SetFocus;
0
 
esoftbgCommented:
//........
            (Components[I] as TWinControl).SetFocus; // Hope this helps ....          
//........

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.