using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace RandomImage { public partial class Form1 : Form { private List<Image> listofImage = new List<Image>(); private Random randomnumber = new Random(); public Form1() {
InitializeComponent(); for (int i = 1; i <= 8; i++)//8 images add to list listofImage { Image im = Image.FromFile(i.ToString() + ".jpg"); listofImage.Add(im); } } private void timer1_Tick(object sender, EventArgs e) { this.BackgroundImage = listofImage[randomnumber.Next(1, 8)];//Select random number from List } } }
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
thank you it was harder than i thought
Leave a comment