简体   繁体   中英

How can I load images from the hard disk and display them in pictureBox with timer?

private void timer1_Tick(object sender, EventArgs e)
        {
            foreach (string image in filesRadar)
            {
                pictureBox1.Load(image);
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            foreach (string image in filesSatellite)
            {
                pictureBox2.Load(image);
            }
        }

I'm not getting any errors/exceptions and using breakpoint it stop on the Load line/s but it's not showing the images on any of the pictureBoxes.

This is working. could be in other ways but it's working.

        int radImagesCount = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            radImagesCount++;

            if (radImagesCount == filesRadar.Length)
            {
                radImagesCount = 0;
            }

            pictureBox1.Image = new Bitmap(filesRadar[radImagesCount]);
        }

        int satImagesCount = 0;
        private void timer2_Tick(object sender, EventArgs e)
        {
            satImagesCount++;

            if (satImagesCount == filesSatellite.Length)
            {
                satImagesCount = 0;
            }

            pictureBox2.Image = new Bitmap(filesSatellite[satImagesCount]);
        }

Both filesRadar and filesSatellite are string[] arrays contains the images fils.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM