component property
-
Hi, how I can acces properties of component I created: I create 2 label in my form1, and later I want to get text from each of those labels I think it should look like this foreach(Label l in Form1.label) { console.write(l.text); } but I`m wrong...
-
Hi, how I can acces properties of component I created: I create 2 label in my form1, and later I want to get text from each of those labels I think it should look like this foreach(Label l in Form1.label) { console.write(l.text); } but I`m wrong...
-
Try this code:
foreach(Control ctrl in form1.Controls) { if (ctrl is Label) { console.write(((Label)ctrl).Text); } }
Best regards, Alexey.First of all thank you for your answer, but I get this error An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Controls.get'
-
First of all thank you for your answer, but I get this error An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Controls.get'
Sorry everything is now working:) thank you very much