2

我有一个图片框(称为 pic_Image)和 2 个按钮(称为 btn_AddImage 和 btn_RemoveImage)。我想让按钮在用户在 pic_Image 上移动鼠标时可见,并在鼠标离开 pic_Image 时使它们不可见。这是使可见的代码:

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 单击方法不起作用。

提前致谢

4

1 回答 1

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;
}
于 2013-04-05T07:14:14.107 回答