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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sateesh ArvetiRank #96 · 22.3K reputationPosted Jul 14, 2008, 11:40 PM EDT
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";
}