C# 使用PictureBox控件--点击切换图片

时间:2023-04-21 21:07:14

效果:

1.

C# 使用PictureBox控件--点击切换图片

2.

C# 使用PictureBox控件--点击切换图片

代码:

         private Boolean fals = true;

         /// <summary>
/// 单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pictureBox3_Click(object sender, EventArgs e)
{
if (fals == true)
{
this.pictureBox3.BackgroundImage = Image.FromFile(Application.StartupPath + "\\image\\" + "stop.ico");
fals = false;
}
else
{
this.pictureBox3.BackgroundImage = Image.FromFile(Application.StartupPath + "\\image\\" + "start.ico");
fals = true;
}
}