Example with ImageList:-



Add a new Form i.e.,FormDigitalAlbum to the Windows Application WABasics

Create one pictureBox,one timer and one imagelist Control 

[imageList1,timer1 will only appear in the Component Tray]

Select imageList1---G oto properties—set the following properties

1.Images—click on Ellipsis button—this will open       Image Collection Editor---in this click on Add Button to Add the images to the collection---click on Ok
2.ImageSize----250,250

Select pictureBox1set the following properties:-

Size             :         250,250     
Design :-



Generate theEventHandler for time1 tick  Event
& write the following code in Source[FormDigitalAlbum.cs] 


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 WABasics
{
    public partial class FormDigitalAlbum : Form
    {
        int i = 0;

        public FormDigitalAlbum()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.Image = imageList1.Images[i];
            i++;
            if (i == imageList1.Images.Count)
            {
                i = 0;
            }
        }  
      
    }
}



Result :-


No comments:

Post a Comment