c#问题 请教问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以在窗体添加一个timer控件,或者自定义timer也可以例如Timer procTimer = new Timer();然后注册timer事件procTimer .Tick += new EventHandler(procTimer _Tick);定义timer函数 void procTimer _Tick(object sender, EventArgs e) { }设置timer计数间隔procTimer.Interval = 100;//默认100毫秒启动timerprocTimer .Start(); 你可以点击按钮后,显示图片,再启动Timer();定时为2秒,再载入第二张图, private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { pictureBox1.Image = Image.FromFile(Application.StartupPath + @"\\images\img2.jpg"); } private void button1_Click(object sender, EventArgs e) { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Load(Application.StartupPath+@"\\images\img1.jpg"); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 2000; timer.Start(); timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); } #4正解!Timer有两个一个是System.Windows.Forms命名空间下的Timer组件(https://msdn.microsoft.com/zh-cn/library/system.windows.forms.timer.aspx)一个是System.Threading命名空间下的Timer类(https://msdn.microsoft.com/zh-cn/library/system.threading.timer.aspx) private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { pictureBox1.Image = Image.FromFile(Application.StartupPath + @"\\images\img2.jpg"); timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed); }否则2秒过后每2秒都会重新读文件,效率太低了 江湖救急啊。。。C#读取Excel文件,有的字符串只能读一半。。。无解啊 数据库问题 关于对象序列化压缩后追加,再反序列化时丢失对象的问题 C#调用SQl存储过程 大家都来看看我们的网站啊!给下意见!来者有分 Directory.CreateDirectory建立文件目录的问题。。。。。。。 ASP.NET State Service 有什么用? C#加密解密源码 对c#程序进行封装?? 有其它方式可让第二个窗体永远显示在主窗体的上方(也不是使用父子窗体的方式) c# 操作 office2007给每一页添加不同的页眉 求C#代码实现PDF文件的添加附注,获取附注的内容
例如
Timer procTimer = new Timer();
然后注册timer事件
procTimer .Tick += new EventHandler(procTimer _Tick);
定义timer函数
void procTimer _Tick(object sender, EventArgs e)
{
}设置timer计数间隔
procTimer.Interval = 100;//默认100毫秒
启动timer
procTimer .Start();
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
pictureBox1.Image = Image.FromFile(Application.StartupPath + @"\\images\img2.jpg");
}
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Load(Application.StartupPath+@"\\images\img1.jpg");
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 2000;
timer.Start();
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
}
Timer有两个
一个是System.Windows.Forms命名空间下的Timer组件(https://msdn.microsoft.com/zh-cn/library/system.windows.forms.timer.aspx)
一个是System.Threading命名空间下的Timer类(https://msdn.microsoft.com/zh-cn/library/system.threading.timer.aspx)
{
pictureBox1.Image = Image.FromFile(Application.StartupPath + @"\\images\img2.jpg");
timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
}
否则2秒过后每2秒都会重新读文件,效率太低了