[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Copy and paste text to and from the clipboard C#

copy and paste clipboard text

Using the clipboard to copy and paste text is simple. Use the Clipboard object's SetText method to copy text to the clipboard as in the following code.

// Copy text to the clipboard. private void btnCopy_Click(object sender, EventArgs e) { Clipboard.SetText(txtCopy.Text); }

Use the Clipboard object's GetText method to retrieve the text that's in the clipboard as in the following code.

// Paste text from the clipboard. private void btnPaste_Click(object sender, EventArgs e) { txtPaste.Text = Clipboard.GetText(); }

That's all there is to it! In later posts I'll show how you can copy and paste other kinds of data such as images or objects of your own creation.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.