: I'm not sure i understood the question
: any way if you want to loop through controls
: you have to:
: 1- make sure your interested controls are in same container (say
: groupBox)
: 2- make sure their tab stops are sequenced
: 3- use the following code
:
:
: OnClick()
: {
: for(int i=0; i<GroupBox1->ControlCount; i++)
: {
: TLabel* activeControl = (TLabel*)GroupBox1->Controls[i];
: activeControl->Caption = IntToStr(i);
: }
: }
: :
:
: note1: if Tab Stops are not in sequence, try to jump with i in the
: loop
: note2: remember that Form is a container itself, so you can use
: Controls[index] without GorupBox preceeding it, but this will affect
: all controls on the form.
:
: Mohammad Nasim
I think it's more save to check if the TControl which you'd like to change is really a 'TLabel'. You should use 'InheritsFrom'.
OnClick()
{
// count all controls
for(int i=0; i<GroupBox1->ControlCount; i++)
{
// check if the control is really a TLabel
if(GroupBox1->Controls[i]->InheritsFrom(__classid(TLabel)))
{
// change the name of the label starting with 1
((TLabel *)GroupBox1->Controls[i])->Name = "Label" + IntToStr(i + 1);
}
}
}
Good luck,
PiSymbol