本文介绍了我想让一个图片框在不使用控件的情况下经过一段时间后消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是 C# 的新手...我有一个图片框,它是我的控件.它旨在快速点击.我想让它被点击一定次数时,第二个带有 .gif 的图片框变得可见.并且当过了一段时间没有点击第一个图片框时,第二个图片框就会消失.有没有办法做到这一点?也许有计时器.一些示例代码将帮助我很多!提前感谢大家!:)

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

推荐答案

试试这个:

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;
}

这篇关于我想让一个图片框在不使用控件的情况下经过一段时间后消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 02:51