Copy and paste text to and from the clipboard C#
Using the clipboard to copy and paste text is simple. Use the Clipboard object's SetText method to copy text to the clipboard.
// Copy text to the clipboard.Use the Clipboard object's GetText method to retrieve the text that's in the clipboard.
private void btnCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(txtCopy.Text);
}
// Paste text from the clipboard.
private void btnPaste_Click(object sender, EventArgs e)
{
txtPaste.Text = Clipboard.GetText();
}


Comments