Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. image slideshow

image slideshow

Scheduled Pinned Locked Moved C#
graphicshelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mist_psycho
    wrote on last edited by
    #1

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer1.Interval = 5000; timer1.Enabled = true; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { for (int i = 0; i < 5 ; i++) { pictureBox1.Image = imageList1.Images[i]; } } } } ************************ every time i run this application only the last image from the image list is displayed. I need to display all d images with 5 seconds delay between each of them !!! plz help needed !!! where am i goin wrong >?????????????

    M J 2 Replies Last reply
    0
    • M mist_psycho

      using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer1.Interval = 5000; timer1.Enabled = true; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { for (int i = 0; i < 5 ; i++) { pictureBox1.Image = imageList1.Images[i]; } } } } ************************ every time i run this application only the last image from the image list is displayed. I need to display all d images with 5 seconds delay between each of them !!! plz help needed !!! where am i goin wrong >?????????????

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      your problem is in your tick event handler. you are looping all the images at once. to solve your problem you need to create a Global index for the image currently being displayed then increment that with every tick and display the appropriate image. Do you understand?

      Life goes very fast. Tomorrow, today is already yesterday.

      M 1 Reply Last reply
      0
      • M mist_psycho

        using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer1.Interval = 5000; timer1.Enabled = true; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { for (int i = 0; i < 5 ; i++) { pictureBox1.Image = imageList1.Images[i]; } } } } ************************ every time i run this application only the last image from the image list is displayed. I need to display all d images with 5 seconds delay between each of them !!! plz help needed !!! where am i goin wrong >?????????????

        J Offline
        J Offline
        jaypatel512
        wrote on last edited by
        #3

        using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { //Variables int currentimageindex = 1; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer1.Interval = 5000; timer1.Enabled = true; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { if(currentimageindex <= 5) { pictureBox1.Image = imageList1.Images[currentimageindex]; currentimageindex++; } else { currentimageindex = 1; } } } } }

        1 Reply Last reply
        0
        • M musefan

          your problem is in your tick event handler. you are looping all the images at once. to solve your problem you need to create a Global index for the image currently being displayed then increment that with every tick and display the appropriate image. Do you understand?

          Life goes very fast. Tomorrow, today is already yesterday.

          M Offline
          M Offline
          mist_psycho
          wrote on last edited by
          #4

          thanks a lot it worked !!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups