我尝试在表单中捕获鼠标单击事件 但它确实有效
部分代码如下
public partial class UIMessage : Form
{
public UIMessage()
{
...
this.MouseClick += UIMessage_MouseClick;
this.KeyDown += UIMessage_KeyDown;
...
}
private void UIMessage_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
Console.WriteLine("Enter");
}
private void UIMessage_MouseClick(object sender, MouseEventArgs e)
{
Console.WriteLine("Click");
}
有人能告诉我代码有什么问题吗?
Key down事件运行良好,但鼠标点击事件不是
答案 0 :(得分:0)
private void UIMessage_Click(object sender, MouseEventArgs e)
{
Console.WriteLine("Click");
}
还没试过,但看看它是否有效。仅使用Click
。