首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

C# 圖片瀏覽器幻燈片:Timer + ImageList 實現自動切換

     編輯:程式設計綜合問答

核心邏輯:

int idx = 0;
ImageList imgList = new ImageList();
// 加載圖片到 imgList.Images

timer.Interval = seconds * 1000;
timer.Tick += (s, e) => {
    if (idx >= imgList.Images.Count) idx = 0;
    pictureBox.Image = imgList.Images[idx++];
};
btnStart.Click += (s, e) => timer.Start();
btnStop.Click += (s, e) => timer.Stop();

間隔由 ComboBox 輸入秒數換算毫秒。簡單高效,無需模擬按鈕點擊。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved