C#中对工具栏的按钮实现实时禁用与可用

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:49:10
我做了一个程序,希望能让工具栏上的剪切和粘贴按钮对textbox内的内容实现实时的禁用与可用,应该怎么做?
我注意到有些地方提示用Application.Idle 事件,该怎么做?这个事件怎么添加?事件内容又该怎么写?
不要光给个剪切Button.Enable=false;粘贴Button.Enable=false;就拿分闪人...

重写你想监听的控件
[DllImport("user32.dll")]
public static extern int SetClipboardViewer(int windowHandle);

protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
if (message.Msg == WM_DRAWCLIPBOARD)
{
if (Clipboard.ContainsText())
{
MessageBox.Show("Can Paste");
}
else
{
MessageBox.Show("Can not Paste");
}
}
}

需求一点都不清楚,什么时候可用什么时候禁用,什么都没将

Application.Idle 是什么东西。