i want to build an application that automatically floods a text box with text from another text box on button click. i dont even know where to begin

Recommended Answers

All 4 Replies

You can use a timer. Put a button on your form and trigger the button_click event for it. Create a timer and trigger the timer_tick event. In the button_click event start the timer. In the timer_tick event use compound assignment operator += to assign and add the text from one text box to the other.

private void Button_Click(object sender, EventArgs e)
{
timer1.Start();
}

private void Timer_Tick(object sender, EventArgs e)
{
textBox2.Text += textBox1.Text;
}

To add a new line each time on top of the text, just add + Environment.NewLine to the end of the statement. But unless you're using a richtextbox make sure you set the Multiline property of your textbox to true.

thank you!

Also, how would I add the new line?

Okay, as I just stated, simply add Environment.NewLine to the end of the statement.

private void Button_Click(object sender, EventArgs e)
{
textBox2.Multiline = true;
timer1.Start();
}

private void Timer_Tick(object sender, EventArgs e)
{
textBox2.Text += textBox1.Text + Environment.NewLine;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.