I want to make a picturebox disappear after a certain time has passed without using a control

大兔子大兔子 提交于 2021-02-08 11:24:18

问题


Hello I am kind of new to C#... I have a picturebox which is my control. It's meant to be rapidly clicked on. I want to make it so when it is clicked a certain amount of times a second picturebox which has a .gif in it becomes visible. And when a certain amount of time has past without clicking the first picturebox the second disappears. Is there a way to do this? Maybe with timers. Some sample code will help me out A LOT! Thanks to all in advance! :)


回答1:


Try This:

System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
timer1.Interval=60000;//one minute
timer1.Tick += new System.EventHandler(timer1_Tick);
timer1.Start();

private void pictureBox1_Click(object sender, EventArgs e)
{       
    timer1.Stop();
    timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
    //do whatever you want            
    pictureBox2.Visible = false;
}


来源:https://stackoverflow.com/questions/22425257/i-want-to-make-a-picturebox-disappear-after-a-certain-time-has-passed-without-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!