Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Special Offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com

Blogspot  greatis.blogspot.com

 See more ads about delphi programming →


Get component index at runtime - Components - Tips & Tricks - Greatis Delphi Pages

Use IndexInParent function:


procedure TForm1.Button3Click(Sender: TObject);
begin
  MessageBox(
    Handle, 
    PChar('Index = '+IntToStr(IndexInParent(Button3))),
    'Information',  
    MB_OK);
end;

function TForm1.IndexInParent(VControl: TControl): Integer;
var
  ParentControl: TWinControl;
begin
  ParentControl:=TForm(VControl.Parent);
  if (ParentControl<>nil) then
    for Result:=0 to ParentControl.ControlCount-1 do
      if (ParentControl.Controls[Result]=VControl) then
        Exit;
  Result:=-1;
end;
For more
Delphi Help

Download source


 See more ads about delphi components →