Merhaba arkadaşlar, bu makalemizde images klasöründe
bulunan resimleri random olarak PictureBox nesnesinde göstereceğiz. Formumuza
PictureBox ve Timer ekleyeceğiz.
Screenshot
Şekil
1
Şekil
2
Form1.cs
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[] ImagePath = Directory.GetFiles(@"images/", "*.jpg");
       
private void Form1_Load(object sender, EventArgs e)
       
{
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            timer1.Start();
            timer1.Interval = 1000;
       
}
       
private void timer1_Tick(object sender, EventArgs e)
       
{
            Random rnd = new Random();
            pictureBox1.ImageLocation =
ImagePath[rnd.Next(0, ImagePath.Length)];
       
}
   
}
}
Bir makalenin daha sonuna geldik. Bir sonraki makalede
görüşmek üzere. Bahadır ŞAHİN


0 comments:
Yorum Gönder