我有一个picturebox(称为pic_Image)和2个按钮(称为btn_AddImage& btn_RemoveImage)。我希望当用户在pic_Image上移动鼠标时使按钮可见,并在鼠标离开pic_Image时使其成为invisibe。 这是使可见的代码:
private void pic_Image_MouseMove(object sender, MouseEventArgs e)
{
btn_AddImage.Visible = true;
btn_RemoveImage.Visible = true;
}
这是隐藏的代码:
private void pic_Image_MouseLeave(object sender, EventArgs e)
{
btn_AddImage.Visible = false;
btn_RemoveImage.Visible = false;
}
问题是我使用pic_Image_MouseMove方法后,Onbutton click方法不起作用。
提前致谢
答案 0 :(得分:1)
鼠标电影事件不断触发,直到鼠标在图片上 用鼠标输入
替换鼠标移动private void pic_Image_MouseEnter(object sender, MouseEventArgs e)
{
btn_AddImage.Visible = true;
btn_RemoveImage.Visible = true;
if (pic_Image.Image != null)
btn_RemoveImage.Visible = true;
}