c# - How to write to a dynamical number of Textboxes? -


I have a form with a dynamically-generated text box (Windows Forms):

 < Code> textbox [] TbxCantServ = new text box [1]; Int i; (I = 0; i & lt; tbxCantServ.Length; i ++) for {tbxCantServ [i] = new text box (); } Forchha (Texbox TBXactive Kant in TBX Kantserve) {TBXactive Kant. Location = new point (Ihorizontal, ivertical); TbxActualCant.Name = "tbx" + Counter ++; TbxActualCant.Visible = True; TBXVivial Kent With = 44; TBXActualCent.maxelanel = 4; This.Controls.Add (tbxActualCant); }  

Now I want to fill them with data, how can I do this?

If I have made some text boxes dynamic with names:

"TBX Activated Acer. Name =" TXT + "Counter;"

How can I write them? For example, if I made TBX1, TBX2 and TBX3, then I would have "for" which fills TBX1. Text with "1", TBX2 With text "2", and tbx3.Text "3"

Like something like

like this:

/ P>

  this.Controls.OfType & lt; TextBox & gt; (). Where (r = & gt; r.Name == "tbx" + counter). ¿¿Type ?? (R = & gt; r.Text = i) .ostring ();  

Thanks!

You can do something like this:

  this.Controls OfType & lt; TextBox & gt; (). ToList & lt; Text box & gt; (). ForEach (tb = & gt; tb.Text = "bla bla");  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -