From Clomosy Docs
Form1.clFindComponent(xObjectName : String): TCLComponent;
To find another component under a component or form, clFindComponent is used. This method allows you to search for a specific named subcomponent. This allows making changes to the properties of the found component.
Within this feature, a string parameter is accepted, and this parameter is the name of the variable.
Example
In the example, we can determine which of the multiple buttons created using the clSender feature we clicked on and change the button text using the clFindComponent property.
Var
MyForm:TclForm;
mainPnl : TclProPanel;
testBtn : TClProButton;
i,j : Integer;
Combo1 : TClComboBox;
void ComboSelected;
var
strKey : String;
{
strKey = Combo1.GetItemIndex(Combo1.ItemIndex);
if (Combo1.ItemIndex <> '0')
{
TClProButton(MyForm.clFindComponent(strKey)).Caption = strKey+'+';
TClProButton(MyForm.clFindComponent(strKey)).Enabled = false;
}
}
{
MyForm =TclForm.Create(self);
Combo1 = MyForm.AddNewComboBox(MyForm,'Combo1');
Combo1.Align = alMostTop;
Combo1.Height = 20;
Combo1.Margins.Top=10;
Combo1.Margins.Left =MyForm.clWidth/9;
Combo1.Margins.Right =MyForm.clWidth/9;
Combo1.AddItem('Please select the button to be marked.','0');
for (j = 1 to 5)
Combo1.AddItem('testBtn'+IntToStr(j),IntToStr(j));
MyForm.AddNewEvent(Combo1,tbeOnChange,'ComboSelected');
mainPnl=MyForm.AddNewProPanel(MyForm,'mainPnl');
mainPnl.Align = AlCenter;
mainPnl.Width = 200;
mainPnl.Height = 300;
mainPnl.clProSettings.IsRound = True;
mainPnl.clProSettings.RoundHeight = 10;
mainPnl.clProSettings.RoundWidth = 10;
mainPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#3a32a8');
mainPnl.clProSettings.BorderWidth = 2;
mainPnl.SetclProSettings(mainPnl.clProSettings);
for (i = 0 to 4)
{
testBtn = MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),'');
testBtn.Align = AlTop;
testBtn.caption = 'testBtn'+IntToStr(i+1);
testBtn.Margins.Right = 5;
testBtn.Margins.Left = 5;
testBtn.Margins.Top = 5;
testBtn.Height = 50;
MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png');
}
MyForm.Run;
}