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

StackOverflow https://stackoverflow.com/questions/22425257

  •  15-06-2023
  •  | 
  •  

Domanda

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! :)

È stato utile?

Soluzione

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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top