// Rasgele Isim Çekme | Ali AKYILDIRIM | www.aliakyildirim.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// Rasgele Isim Çekme | Ali AKYILDIRIM | www.aliakyildirim.com
namespace KurbanSec
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.BackColor = Color.LightGray;
try
{
// Rastgele Çekilecek Isimlerden Bir Dizi Olusturalim:
string[] herkes = { " Dilara", " Mustafa", " Deniz", " Kadir", " Ugur", " Fikret", " Onur", " Serdar", " Umut", " Kenan", " Abdullah", " Gökhan", " Ali", " Tugçe", " Okan" };
Random rnd = new Random();
int sansliIndex = rnd.Next(0, herkes.Length);
string secilenUnlu = herkes[sansliIndex];
if (!lstKisiler.Items.Contains(secilenUnlu))
{
lstKisiler.Items.Add(secilenUnlu); button1.BackColor = Color.Wheat; button1.ForeColor = Color.Green;
button1.Enabled = false;
}
else
{
try
{
button1.PerformClick();
//Herbastiginda tiklanmis gibi olsun..
}
catch (Exception)
{
MessageBox.Show("Bir Hata Olustu..!");
}
}
}
catch (Exception)
{
MessageBox.Show("Bir Hata Olustu..!");
}
}
private void button2_Click(object sender, EventArgs e)
{
button1.BackColor = Color.Wheat;
lstKisiler.Items.Clear();
button1.Enabled = true;
}
private void button1_MouseHover(object sender, EventArgs e)
{
button1.BackColor = Color.LightYellow;
}
private void groupBox1_Enter(object sender, EventArgs e)
{
button1.BackColor = Color.Wheat;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
button1.BackColor = Color.Wheat;
}
}
}
// Rasgele Isim Çekme | Ali AKYILDIRIM | www.aliakyildirim.com
Kaynak: Bu Örnek, Bilge Adam egitimi Sirasinda Türkay Ürkmez Tarafindan Yapilmis ve Yazilimcik.com ailesi tarafindan gelistirilmistir.