Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
How to order Windows to copy in C#? copy any thing that is selected, just like sending Ctrl+C, or how to send Ctrl+C in C#? Windows Forms Applications
Posted
Updated 9-Dec-14 8:39am
v3
Comments
Sergey Alexandrovich Kryukov 9-Dec-14 14:57pm    
Don't use SendKeys! This is a big abuse.
—SA

In C#, you don't "order Windows to copy" to the clipboard: instead, you use the Clipboard class[^] to copy things onto it:
C#
Clipboard.SetText(myTextBox.Text);


But be very careful: if you start overwriting the clipboard content without the user's knowledge, your software will stand a very, very good chance of being uninstalled with extreme prejudice. Many people use the clipboard a lot, and do not take kindly to you overwriting their data...
 
Share this answer
 
Comments
john1990_1 9-Dec-14 14:44pm    
i want to send keys (ctrl+c) or order Windows to copy whatever is selected (in whatever program the user is)?
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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