Hi,
I add some controls during runtime and name them with a label + integer.
How do i grab these controls later on? Say i want to change the text in label4 as an example.
Hi,
I add some controls during runtime and name them with a label + integer.
How do i grab these controls later on? Say i want to change the text in label4 as an example.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sateesh ArvetiPosted Jul 15, 2008, 3:40 AM
We can find controls added to a form at runtime by using Find() method.Please,have a look at the below code:
//Here,We have to pass Button Control Name as key to Find method.
Control[] btns = this.Controls.Find("Control1", true);
if (btns.Length > 0)
{
((Button)btns[0]).Text = "test123";
}