blah blah blah is here! blah blah » Close

up1down
link

I need to be able to select, copy, and paste text in a windows form application.

Can someone help me with this please?

last answered 2 years ago

1 answers

up2down
link

When button1 is pressed, the following code selects all the text in textBox1, copies it to the clipboard and then pastes it to textBox2:

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
textBox1.Focus();
textBox1.SelectAll();
Clipboard.Clear();
Clipboard.SetText(textBox1.SelectedText);
textBox2.Text = Clipboard.GetText();
}
}

Feedback