选择困难症今天吃什么图片轮播神器,让它为你选择
winform界面,一个开始按钮,三次机会,点击开始出现食物图片轮播

类似于抽奖那种。
窗体界面就这样搭建

图片显示控件 pictureBox
图片存储容器 imageList
轮播功能通过 Timer控件实现 /100s
点击开始轮播按钮Button
文字显示两个Label
在Button控件里写代码
if (button1.Text == "开始")
{
if (count >= 3)
{
label2.Text = "别挑了,就吃这个";
button1.Enabled = false;
return;
}
count++;
label2.Text = string.Empty;
timer1.Start();
button1.Text = "停止";
}
else
{
label2.Text = "今天吃这个";
timer1.Stop();
button1.Text = "开始";
}
在Timer控件里写代码
if (index < imageList1.Images.Count)
{
pictureBox1.Image = imageList1.Images[index];
label1.Text = imageList1.Tag.ToString().Split(',')[index].Replace(".jpg","");
index++;
}
else
{
index = 0;
}
链接:https://pan.baidu.com/s/1FNMae0LRBg9GfR2gqGNuEQ?pwd=40ho
提取码:40ho

浙公网安备 33010602011771号