How do I change the property of a control in the flowlayout panel, assuming you add controls programmatically and think that the name of each control is the same?
For example, this image shows you that there are 2 text fields and two buttons, how would I change the back color of button 2? Assuming controls were added at runtime.
foreach(Controls ctrl in flowlayoutpanel1.Controls) { //What should I put here? }
, - . , ( i18n). . "button2" "button2" , :
foreach (Control ctl in flp.Controls) { if ("button2".Equals(ctl.Tag)) { ctl.BackColor = Color.Red; }
}
, , . , , - "button2" , , , , .
ETA: , Name.
Name
, sender .
sender
Control.ControlCollection.Find.
flowLayoutPanel1.Controls.Add(new Button() { Text = "button 1", Name = "btn1" }); Button btn1 = flowLayoutPanel1.Controls.Find("btn1", true).FirstOrDefault() as Button; btn1.Text = "found!";
Source: https://habr.com/ru/post/1768554/More articles:Когда загружать текстуры? - windows-phone-7PHP: Facebook / Twitter integration - phpListView Losing Selection before running Drag - wpfWhat physical Android device are you using for testing purposes? - androidAlternatives to SQL Server Express beyond 2 GB - databaseHow to interpret complete programs in Ready Lisp? - installationHow to Optimize Lucene.Net Indexing - luceneMakeSfxCA.exe and DLL compiled with Framework 4.0 - .netphp_excel07- how to replicate properties of one row to the next row - phpNetbeans IDE 6.91 "центр по горизонтали" не доступен для кликов - javaAll Articles