using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections; //Arraylist İçin Eklemelisiniz.
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GenelFormUygulamasi
{
    public partial class Form1 : Form
    {
        ArrayList TcNo = new ArrayList();
        string aranan;
        int yer = -1;
        Random rastgele = new Random();

        public Form1()
        {
            InitializeComponent();
        }

        private void BtnHafizayaEkle_Click(object sender, EventArgs e)
        {
            TcNo.Add(TxtKimlikNo.Text +"-"+ TxtAd.Text.PadLeft(10) + TxtSoyad.Text.PadLeft(15) +"-"+ maskedTxtTelNo.Text.PadLeft(20));
        }

        private void BtnListeyeEkle_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            foreach (string numara in TcNo)
            {
                listBox1.Items.Add(numara);
            }
        }

        private void BtnRastgeleSecim_Click(object sender, EventArgs e)
        {
            int sayi;

            sayi = rastgele.Next(TcNo.Count);

            MessageBox.Show("Kayıtlar Arasından  " + TcNo[sayi].ToString() + " numaralı kullanıcı şanslı kullanıcı olarak seçilmiştir");
        }

        private void BtnSil_Click(object sender, EventArgs e)
        {
            listBox1.Items.Remove(listBox1.SelectedItem);
        }
        private void BtnAra_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 BtnSonrakiniBul_Click(object sender, EventArgs e)
        {
            if (yer < listBox1.Items.Count - 1)
            {
                yer = listBox1.FindString(aranan, yer);
                if (yer >= 0)
                    listBox1.SelectedIndex = yer;
            }
        }
    }
}


Dosyayı İndir