复制到剪贴板 [英] Copying to the clipboard

查看:128
本文介绍了复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



....使用visualweb.net 2005和vb。


....试图简单地将文本框中的内容复制到剪贴板。


我看了很多地方在线,他们给了我各种

代码,但它不起作用。我显然错过了某种类型的声明,

和visualweb.net中的代码比其他地方的代码差。

当我尝试下面的代码时,它告诉我名称剪贴板不是

声明


我缺少什么?


谢谢


Jeff

受保护的子BtnCopy_Click(ByVal发送者为对象,ByVal e As

System.EventArgs)处理BtnCopy.Click

Clipboard.SetDataObject(TextBox1.Text)

End Sub


-

通过免费的Usenet帐户发布来自 http://www.teranews.com


....working with visualweb.net 2005 and vb.

....trying to simply copy the contents from a textbox to the clipboard.

I''ve looked at a large number of places on line and they give me various
code, but it doesn''t work. I''m apparently missing some type of declaration,
and the code is diffent in visualweb.net than elsewhere.
When I try the code below, it tells me that the "name clipboard is not
declared"

What am I missing?

Thanks

Jeff
Protected Sub BtnCopy_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnCopy.Click
Clipboard.SetDataObject(TextBox1.Text)
End Sub

--
Posted via a free Usenet account from http://www.teranews.com

推荐答案

如果它没有识别剪贴板的名称,那么你就没有包含导入的Clipboard类的

命名空间。

" Jeff" < no ** @ none.com写信息

news:45 ********************** @ free.teranews.com ...
If it isn''t recognizing the name Clipboard, then you haven''t got the
namespace that contains the Clipboard class imported.
"Jeff" <no**@none.comwrote in message
news:45**********************@free.teranews.com...

>

...使用visualweb.net 2005和vb。


...试图简单地将文本框中的内容复制到剪贴板。


我看了很多在线的地方,他们给了我各种

代码,但它不起作用。我显然错过了某种类型的

声明,并且在visualweb.net中的代码与其他地方的代码不同。

当我尝试下面的代码时,它告诉我名称剪贴板不是

声明


我缺少什么?


谢谢


Jeff


受保护的子BtnCopy_Click(ByVal发送者作为对象,ByVal e As

System.EventArgs)处理BtnCopy.Click

Clipboard.SetDataObject(TextBox1.Text)

结束子


-

发表于来自 http://www.teranews.com 的免费Usenet帐户
>
...working with visualweb.net 2005 and vb.

...trying to simply copy the contents from a textbox to the clipboard.

I''ve looked at a large number of places on line and they give me various
code, but it doesn''t work. I''m apparently missing some type of
declaration, and the code is diffent in visualweb.net than elsewhere.
When I try the code below, it tells me that the "name clipboard is not
declared"

What am I missing?

Thanks

Jeff
Protected Sub BtnCopy_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnCopy.Click
Clipboard.SetDataObject(TextBox1.Text)
End Sub

--
Posted via a free Usenet account from http://www.teranews.com





" Scott M." < s - *** @ nospam.nospamwrote in message

news:eU ************** @ TK2MSFTNGP04.phx.gbl ...

"Scott M." <s-***@nospam.nospamwrote in message
news:eU**************@TK2MSFTNGP04.phx.gbl...

如果它没有识别剪贴板的名称,那么你就没有包含导入的Clipboard类的

命名空间。
If it isn''t recognizing the name Clipboard, then you haven''t got the
namespace that contains the Clipboard class imported.



谢谢,但我还是新手。你能解释一下如何做到这一点吗?


Jeff

-

通过 http://www.teranews.com

Thanks, but I''m still new at this. Could you please explain how to do that?

Jeff
--
Posted via a free Usenet account from http://www.teranews.com


Jeff,


看看你是否有一个对''System.Windows.Forms''类的引用开始


然后您可以正常使用您的代码复制到剪贴板


如果您想粘贴剪贴板数据,请使用以下代码:


Dim iData As IDataObject = Clipboard.GetDataObject()

TextBox1.Text = CType(iData.GetData(DataFormats.Text),String)


我使用TextBox1来保存粘贴的文本


我希望这会有所帮助,


新手编码器
Jeff,

See if you have a reference to the ''System.Windows.Forms'' class for a start

Then you can use your code as normal to copy to the clipboard

If you then want to paste the clipboard data then use this code:

Dim iData As IDataObject = Clipboard.GetDataObject()
TextBox1.Text = CType(iData.GetData(DataFormats.Text), String)

I used TextBox1 to hold the pasted text

I hope this helps,

Newbie Coder

这篇关于复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆