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"
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top