Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在c#上,picturebox上的鼠标套似乎什么都不做。我需要某种事件处理程序吗?_C#_Picturebox_Mousehover_Eventhandler - Fatal编程技术网

在c#上,picturebox上的鼠标套似乎什么都不做。我需要某种事件处理程序吗?

在c#上,picturebox上的鼠标套似乎什么都不做。我需要某种事件处理程序吗?,c#,picturebox,mousehover,eventhandler,C#,Picturebox,Mousehover,Eventhandler,我正在尝试为pictureBox创建鼠标悬停事件,但到目前为止我运气不佳: private void pictureBox1_MouseHover(object sender, EventArgs e) { pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07; label1.Text = "hover"; } private void pictureBox1_Click(object sender, EventA

我正在尝试为pictureBox创建鼠标悬停事件,但到目前为止我运气不佳:

private void pictureBox1_MouseHover(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
  label1.Text = "hover";
}

private void pictureBox1_Click(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
}

private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
}

这是怎么回事?MouseClick工作正常,可能我必须在
Form1.Designer.cs

好的,我必须在构造函数上添加这一行: this.pictureBox1.MouseHover+=新的System.EventHandler(this.pictureBox1\u MouseHover);
虽然我会使用鼠标器,但速度更快

请定义“不工作”。这里没有事件绑定代码。没有它,处理程序就不会被触发。我如何添加事件绑定代码?我不知道这是什么在你的构造函数中,你应该有像
pictureBox1.MouseHover+=neweventhandler(pictureBox1\u MouseHover)
您能在那里(或其他地方)检查类似的行并让我们知道吗?关于您的编辑,请向我们展示相关的
Form1.Designer.cs
部分,即
pictureBox1
引用的位置。很可能是缺少事件绑定代码。您可以使用
查找所有引用
,或者查看
InitializeComponent
或表单构造函数。换句话说,如果您知道
pictureBox1\u Click
是如何连接的,那么
pictureBox1\u鼠标盖
也应该有类似的结构。如果没有,那么它永远不会开火。如果有,那么该事件很可能是在食物链的更高层被消费的(可能是PictureBox的
父级
控制?)。