c# - Load Textboxes from array -


There are several lines of my form boxes. The first line is called txtL000 by txtL009, the second line is txtL100 via txtL109, and so on. Under each of these lines, txtT009 is another line of naming boxes txtT000, etc. The user opens the form, I want to load the labeled txtL in an array ... string, what is the name in the corresponding text box Depends on txtT..0. For example, if txtT000 has "ground" in it, I want to load txtL000 through txtL009 with wire from array arrLand. If there is "point" in it, I want to load the txtL000 from txtL009, in which the array will be the wire from the arrpoint. What is the most effective way to do this?

After

The easiest way I can think of is to use a dictionary to store arrays For:

  // If you want, use whatever dictionary you want instead of 'list'. & Lt; String, list & gt; Erase = new dictionary & lt; String, list & gt; (); Private Zero OnTextChanged (object source, EventArgs e) {if (source == txtT000) loadTextBoxes (txtT000.Text, txtL000, txtL001, txtL002, txtL003, txtL004, txtL005, txtL006, txtL007, txtL008, txtL009); // etc} Private Zero LoadTextBoxes (String Keys, Parameter Text Box [Box]] {List MyList = Arrays [Key]; // Check the two barriers at the loop so that you did not get any exception to go outside the index of the textbox array or mylistlist. For (int i = 0; ((i & lt; textboxes.length) & amp; amp; amp;; (i & lt; myList.Count); i ++) Text box [i]. Text = myList [i] .ostring (); }  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -