chart11610
asked on
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(Components[I] as TWinControl).SetFocus; // Hope this helps ....
//........