Solved

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

Posted on 2004-09-17
2
216 Views
Last Modified: 2010-04-05
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.  
0
Comment
Question by:chart11610
2 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 12084407
If Components[i] is TwinControl then
   TwinControl(Components[i]).SetFocus;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12084422
//........
            (Components[I] as TWinControl).SetFocus; // Hope this helps ....          
//........

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question