using System.Windows.Forms;
string text = "Some text for the clipboard";
Clipboard.SetDataObject(text); //clipboard now has "Some text for the clipboard"
text = ""; //zap text so it can be reset...
IDataObject data = Clipboard.GetDataObject();
if(data.GetDataPresent(DataFormats.Text))
{
text = (String)data.GetData(DataFormats.Text);
//text is now back to "Some text for the clipboard"
}
获取和设置剪贴板的数据
最新推荐文章于 2025-07-04 10:05:53 发布
本文介绍了一种使用 C# 在 Windows Forms 应用程序中设置和获取剪贴板文本的方法。通过实例展示了如何将字符串放入剪贴板以及如何从剪贴板中读取该字符串。
4765

被折叠的 条评论
为什么被折叠?



