关于复制和粘贴 [英] Regarding copy and paste
问题描述
我正在C#.net visual studio 2010中制作一个计算器。但我想复制我的文本框的文本
并将其粘贴到窗口中的任何位置'' s wordpad,记事本等。这怎么可能在c#中。请指导我
I am making a calculator in C#.net visual studio 2010. but i want to copy the text of my textbox
and paste it to anywhere in window''s wordpad,notepad etc. how this can possible in c#. Please guide me
推荐答案
复制到剪贴板很简单:
Copying to the clipboard is easy:
Clipboard.SetText(myTextBox.Text);
如果你想直接用C#而不是让用户这样做,那么粘贴到其他应用程序会更困难。您可以通过 SendKeys [ ^ ]但说实话,那不是' 好的做法:如果你的应用程序开始搞乱我的剪贴板只是为了将信息转移到Word或Excel,那么我会以极端的偏见取消它。
你是什么试图实现你认为这是一个必要的好主意?
Pasting into other applications is harder, if you want to do it directly from C# rather than letting the user do it. You can do it via SendKeys[^] but to be honest, that isn''t a good practice: if your application started messing with my clipoard just to transfer info to Word or Excel, then I would unistall it with extreme prejudice.
What are you trying to achieve that you think this is a necessary and good idea?
这篇关于关于复制和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!