110,546
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button_lock_Click(object sender, EventArgs e)
{
if (this.BackgroundImage == new Bitmap(this.GetType(), "lock_32p.png"))
{
this.BackgroundImage = new Bitmap(this.GetType(), "unlock_32p.png");
}
else
this.BackgroundImage = new Bitmap(this.GetType(), "lock_32p.png");
}
}
if (button_lock.BackgroundImage == Properties.Resources.lock_32p)
{
button_lock.BackgroundImage = Properties.Resources.unlock_32p;
}
else
button_lock.BackgroundImage = Properties.Resources.lock_32p;
就没有找不到资源的问题了,
但是无法判断button_lock.BackgroundImage == Properties.Resources.lock_32p 直接跳到else里面了,不知道这里该怎么判定是lock图还是unlock图 if (button_lock.BackgroundImage == Properties.Resources.lock_32p)
{
button_lock.BackgroundImage = Properties.Resources.unlock_32p;
}
else
button_lock.BackgroundImage = Properties.Resources.lock_32p;
就没有找不到资源的问题了,
但是无法判断button_lock.BackgroundImage == Properties.Resources.lock_32p 直接跳到else里面了Bitmap bmp2 = new Bitmap("c:\\button.gif");