找不到类型或命名空间名称"剪贴板事件参数"



嗨,启动了一个新的应用程序,我需要实现复制到剪贴板以检测用户是否从文本框中复制了文本,我尝试使用此示例,但出现此错误:

The type or namespace name 'ClipboardEventArgs' could not be found

这是我用来解决问题的课程,但它似乎我失败了一些东西。

我的班级

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace OpenPop.TestApplication
{
public partial class ClipboardTextBox : TextBox
{
private const int WM_CUT = 0x0300;
private const int WM_COPY = 0x0301;
private const int WM_PASTE = 0x0302;
public delegate void ClipboardEventHandler(object sender, ClipboardEventArgs e);
[Category("Clipboard")]
public event ClipboardEventHandler CutText;
[Category("Clipboard")]
public event ClipboardEventHandler CopiedText;
[Category("Clipboard")]
public event ClipboardEventHandler PastedText;
public ClipboardTextBox()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_CUT)
{
if (CutText != null)
CutText(this, new ClipboardEventArgs(this.SelectedText));
}
else if (m.Msg == WM_COPY)
{
if (CopiedText != null)
CopiedText(this, new ClipboardEventArgs(this.SelectedText));
}
else if (m.Msg == WM_PASTE)
{
if (PastedText != null)
PastedText(this, new ClipboardEventArgs(Clipboard.GetText()));
}
base.WndProc(ref m);
}
}
}
}

好吧,事实上我以不同的方式解决了这个问题,所以我删除了这个类,我把这个类都替换为

private void button1_Click(object sender, EventArgs e)
{
Clipboard.SetText(messageTextBox.SelectedText);
MessageBox.Show("You Have Copy The Link The Message Will Bee Delete Now...");
deletemenssage();
}

最新更新