How to change Background image as a slider in windows forms application c#

March 07, 2015 0 Comments

Change background look attractive and different. If you want to change background with image also you want to put image slider in background, read this article carefully. Before put some images in background must to add some images in resource folder. Learn How to add images in resources folder: follow the mentioned path which is given below

Expand properties -->Resources-->Add Resource-->Add existing file

Now, set the Background image of the form through code file, add line of code before InitializeComponent() method.

   public Form1()
            this.BackgroundImage = Properties.Resources._007;


Now, Take a timer a control with Tick event also set the timer interval. After every interval image should be change. Now, copy the following code and paste in the code file:

Class constructor code:

 public Form1()
            this.BackgroundImage = Properties.Resources.banner;
            Timer tm = new Timer();
            tm.Interval = 1000;
           tm.Tick += new EventHandler(changeimage);

Definition of the function

  private void changeimage(object sender, EventArgs e)
            List<Bitmap> b1 = new List<Bitmap>();
            var timeget = DateTime.Now.Second % b1.Count;
            this.BackgroundImage = b1[timeget];

  1. Timer control with 1 sec interval.
  2. After 1 sec timer control raise tick event handler code.
  3. List with image type.
  4. Add some images in the list.
  5. Find the remainder by the list of item on every second.
If you want to see the full code with output -- see this video

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google