Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
This is difficult to sya, but I w basically like to know how to change the textBox being used to save lines, for example, similar to how you can put a variable within a string that changes the string, make the textbox line change ffrom text being put into textBox1, into textBox2 after the first loop (could use counter).

C#
if (counter < 5)
{
    textBox1 = "A CHANGING VALUE"
    counter++;
}


So maybe somehow, textBox1, could become textBox2 after the first loop using a counter??
Posted

1 solution

Easy!
C#
TextBox outputTo = textBox1;
for (counter = 0; counter < 10; counter++)
   {
   outputTo.Text = "A CHANGING VALUE " + counter;
   ...
   outputTo = textBox2; 
   }
 
Share this answer
 
Comments
Member 10786148 3-May-14 13:00pm    
That has worked fine, but now when trying to do it for a pictureBox, I change the .Name instead and still doesnt seem to do what I want
OriginalGriff 4-May-14 4:29am    
Changing the Name property for a control doesn't change the actual control instance, anymore than renaming a "rose" to "daffodil" will make it yellow! :laugh:

What are you trying to do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900