首页 > 其他 > 详细

图片轮播

时间:2017-03-01 15:59:11      阅读:200      评论:0      收藏:0      [点我收藏+]

   用了两天时间,学了下c#,写几个简单的demo.

点击按钮,实现图片轮播功能   

  1  添加button  ,picturebox  ,timer组件; 

  2  添加资源文件 ,将本地的图片添加到项目中,属性设置为可嵌入资源;

  3  

//图片轮播
Image[] temp = new Image[4];
private void button1_Click(object sender, EventArgs e)
{

timer1.Enabled = true;
temp[0] = CollapseContainerTest.Resource1.aaa;
temp[1] = CollapseContainerTest.Resource1.sfwqgh;
temp[2] = CollapseContainerTest.Resource1._111;
temp[3] = CollapseContainerTest.Resource1._222;
}

 

//编写计时器代码  ,并在属性中设置间隔时间

int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Image = temp[i++];
//图片适应box大小
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
if (i == 4)
{
i = 0;
}
}

图片轮播

原文:http://www.cnblogs.com/leiWJ/p/6484407.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!