如何制作一个按钮,将我剪贴板上的内容粘贴到任何位置?(How can i make a button that pastes what's on my clipboard to any location? [closed])
我是C#的新手,所以..我想制作一个按钮,将我的TextBox上的内容粘贴到任何文本表单上。
示例:我在Textbox上写了一些内容。我按下按钮,然后按钮复制此文本框中的内容,当我点击某些内容时,它会自动粘贴它。
我已经完成了“复制”部分,我只需要做“粘贴”部分。
谢谢!
I'm new to C#, so.. I want to make a button that pastes what's on my TextBox to any text form.
Example: I write something on my Textbox.A I press the button, then the button copy what's in this textbox and when i click something it will automatically paste it.
I already did the "Copy" part, i just need to do the "Paste" part.
Thank you!
最满意答案
如果您的任务是在表单外部粘贴此文本,则可以使用此代码。
private void button1_Click(object sender, EventArgs e) { Clipboard.SetText(textBox1.Text); Deactivate += Form1_Deactivate; //next click will invoke the Form's Deactivate event } private void Form1_Deactivate(object sender, EventArgs e) { SendKeys.Send("^v"); Deactivate -= Form1_Deactivate; }If your task is to paste this text once outside the form, then you can use this code.
private void button1_Click(object sender, EventArgs e) { Clipboard.SetText(textBox1.Text); Deactivate += Form1_Deactivate; //next click will invoke the Form's Deactivate event } private void Form1_Deactivate(object sender, EventArgs e) { SendKeys.Send("^v"); Deactivate -= Form1_Deactivate; }更多推荐
粘贴,内容,TextBox,按钮,电脑培训,计算机培训,IT培训"/> <meta name="description&
发布评论