Nasıl Yapılır

C# İle Örnekler #41

c

C

PictureBox’ ta Rasgele Resim Gösterisi

Timer ve Picturebox

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }
        string[] dosyalar = Directory.GetFiles(@"D:\resim\","*.jpg");
 
        private void Form1_Load(object sender, EventArgs e)
        {
           
            timer1.Interval = 2000;
           
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
           
            Random r = new Random();
            pictureBox1.ImageLocation = dosyalar[r.Next(0,dosyalar.Length)];
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
        }
    }
}

 

Yazar Hakkında

Hız Hosting

Yorum Yap