using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text!="")
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int indexkac = listBox1.SelectedIndex;
if (indexkac >= 0)
{
textBox1.Text = listBox1.SelectedItem.ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
Random r = new Random();
int sayi;
sayi = r.Next(0, listBox1.Items.Count);
listBox1.SelectedIndex = sayi;
MessageBox.Show("Seçilen kişi: " + listBox1.SelectedItem.ToString(), "Kişi seçildi!", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = "";
}
}
}