如何制作一个按钮,将我剪贴板上的内容粘贴到任何位置?(How can i make a button that pastes what's on my clipboard to any lo

编程入门 行业动态 更新时间:2024-10-28 01:16:56
如何制作一个按钮,将我剪贴板上的内容粘贴到任何位置?(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&

本文发布于:2023-08-01 04:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1354050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:将我   板上   按钮   位置   内容

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!