我已经为我的按钮创建了此代码,但是图像没有更改,为什么?

private void pictureBox94_Click(object sender, EventArgs e)
        {
            if (pictureBox94.Image == Properties.Resources.vuoto)
            {
                pictureBox94.Image = Properties.Resources.select;
                checkBox3.Checked = true;
            }
            else
            {
                pictureBox94.Image = Properties.Resources.vuoto;
                checkBox3.Checked = false;
            }
        }


任何错误!

最佳答案

将您的方法重构为在天气检查时选中复选框,而不是检查图像公平性:

private void pictureBox94_Click(object sender, EventArgs e)
{
    if (!checkBox3.Checked)
    {
        pictureBox94.Image = Properties.Resources.select;
    }
    else
    {
        pictureBox94.Image = Properties.Resources.vuoto;
    }

    checkBox3.Checked = !checkBox3.Checked;
}

10-08 18:53