getting a control from its name

  • Thread starter Thread starter Etienne
  • Start date Start date
E

Etienne

On a Form, I'd like to do something like that, in C++

String *labelName = "myLabel" ;
....
this->Controls[labelName]->Text = "foo" ;

Of course, this doesn't works!
Could you help me?

Thanks!
 
String *labelName = "myLabel
int idx

for(idx = 0; idx < this->Controls->Count; idx++)
if (String::Compare(this->Controls->Item[idx]->Name, labelName) == 0)
break



if (idx < this->Controls->Count)
this->Controls->Item[idx]->Text = "foo"
}
 
Back
Top