label的text属性和pictureBox的Image怎么重赋值?
abel2.Text = " ";
pictureBox3.Image = null;
两个控件先为空,我想再赋值;
label2.Text = "你好! ";
pictureBox3.Image = System.Drawing.Image.FromFile( "E:\\图片\\d567.GIF ");
------解决方案--------------------private void timer1_Tick(object sender, System.EventArgs e)
{
label1.Text = "Now: "+System.DateTime.Now.ToString();
label1.Invalidate();
if (System.DateTime.Now.Hour == 17 && System.DateTime.Now.Minute == 17)
{
this.Show();
this.WindowState = FormWindowState.Normal;
label2.Text = "上课啦!新的一天开始了! ";
pictureBox3.Image = System.Drawing.Image.FromFile( "E:\\图片\\实验用图片\\d2.GIF ");
PlaySound( "1.wav ",
0,
SND_FILENAME | SND_ASYNC);
}
else if (System.DateTime.Now.Hour == 17 && System.DateTime.Now.Minute == 19)
{
this.Show();
this.WindowState = FormWindowState.Normal;
label2.Text = "您辛苦啦!下课休息一下吧! ";
pictureBox3.Image = System.Drawing.Image.FromFile( "E:\\图片\\实验用图片\\d1.GIF ");
PlaySound( "2.wav ",
0,
SND_FILENAME | SND_ASYNC);
}
else
{
label2.Text = " ";
pictureBox3.Image = null;
}
}
这样写,像你那样写直接进第二if,当然不会再进第三个if了
------解决方案--------------------else if(System.DateTime.Now.Hour == 17 && System.DateTime.Now.Minute != 17)
{
label2.Text = " ";
pictureBox3.Image = null;
}
去掉