2MuchRiceMakesMeSick
January 20th, 2007, 03:54 AM
can anyone tell me why this doesnt work?
private: void changeLabel(Label ^ lbl, String ^ str)
{
lbl->Text = str;
}
changeLabel("lblTest", "testing");
Zaccheus
January 20th, 2007, 05:41 AM
What exactly "isn't working" here?
I assume you are getting a compiler error, because passing a String to a function which takes a Label will never compile.
Zaccheus
January 20th, 2007, 06:36 AM
If you want to change the text of a label which is identified by its name, you could try this:
private: void changeLabel(String ^ name, String ^ str)
{
array<Control^>^ controls = Controls->Find(name, true);
for each(Control^ control in controls)
{
control->Text = str;
}
}