Rasgele Kullanıcı Belirleme C#
[code language=”Csharp”]
public partial class Form1 : Form
{
ArrayList tc = new ArrayList();
string aranan;
int yer = -1;
Random ras = new Random();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tc.Add(textBox1.Text+textBox2.Text.PadLeft(10)+textBox3.Text.PadLeft(15)+maskedTextBox1.Text.PadLeft(20));
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
foreach (string numara in tc)
{
listBox1.Items.Add(numara);
}
}
private void button3_Click(object sender, EventArgs e)
{
int sayi;
sayi = ras.Next(tc.Count);
MessageBox.Show("Kayıtlar Arasından " + tc[sayi].ToString()+ " numaralı kullanıcı şanslı kullanıcı olarak seçilmiştir");
}
private void button4_Click(object sender, EventArgs e)
{
listBox1.Items.Remove(listBox1.SelectedItem);
}
private void button5_Click(object sender, EventArgs e)
{
aranan=textBox4.Text;
yer=listBox1.FindStringExact(aranan);
if (yer < 0)
{
yer = listBox1.FindString(aranan);
if (yer < 0)
MessageBox.Show("Bulunamadı");
}
if (yer >= 0)
listBox1.SelectedIndex = yer;
}
private void button6_Click(object sender, EventArgs e)
{
if (yer < listBox1.Items.Count – 1)
{
yer = listBox1.FindString(aranan, yer);
if (yer >= 0)
listBox1.SelectedIndex = yer;
}
}
} [/code]
