Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-17
2
Medium Priority
?
220 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 23

Accepted Solution

by:
Ferruccio Accalai earned 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

885 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