RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
IDesigner60.GetComponent Method

Returns the component with the name passed as a parameter.

Pascal
function GetComponent(const Name: string): TComponent;
C++
__fastcall TComponent * GetComponent(const AnsiString Name);

Call GetComponent to access a component given its name. If the component is not in the current root object, the Name parameter should include the name of the entity in which it resides. For example, to obtain a reference to a component in a data module named 'DataModule2', use a line such as

 TheComponent := Designer.GetComponent('DataModule2.Button1'); {Delphi}

 

 TheComponent = Designer->GetComponent("DataModule2->Button1"); // C++

If DataModule2's unit is in the uses clause of the current root object (Delphi) or its header is included by the root object's unit (C++), GetComponent returns the component.

Note: To obtain a reference to a persistent object that is not a component, use the GetObject method instead.
 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!