winform picturebox控件 定时让图片轮播

 1 public partial class FlowChart : Form
 2     {
 3         public FlowChart()
 4         {
 5             InitializeComponent();
 6             
 7 
 8         }
 9 
10         //定义图片集合
11         private List<Image> listImage = new List<Image>();
12         //起始索引0
13         private int imageIndex = 0;
14         private void FlowChart_Load(object sender, EventArgs e)
15         {
16            
17             timer.Start();
18             LoadImages();
19         } 
20         private void timer_Tick(object sender, EventArgs e) 
21        { 
22               timer.Interval = 2000; 
23               pictureBox1.Image = listImage[imageIndex]; 
24               imageIndex++; 
25              if (imageIndex > listImage.Count - 1) 
26                     imageIndex = 0; 
27         } 
28     
29         //加载图片 
30        public void LoadImages()
31       { 
32           string[] aa = Directory.GetFileSystemEntries(@"D:\work\image");
33           for (int i = 0; i < 5; i++)
34           { 
35                listImage.Add(Image.FromFile(aa[i]));  
36            } 
37        } 
38 }

 

posted @ 2020-06-11 16:39  Mr웃ZHANG  阅读(1137)  评论(0编辑  收藏  举报