Test1

Kullanıcı avatarı
awr
Yönetici
Yönetici
Mesajlar: 3130
Kayıt: 31 Tem 2019 15:03
İletişim:

Test1

Mesaj gönderen awr »

public class Ogrenci
{
public int OkulNo { get; set; }
public string Ad { get; set; }
public string Soyad { get; set; }
public string Sinif { get; set; }
public string Il { get; set; }
public string Ilce { get; set; }
public string EPosta { get; set; }
}


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<Ogrenci> oList = new List<Ogrenci>();
private void label2_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = oList;
}

private void button1_Click(object sender, EventArgs e)
{
Ogrenci o = new Ogrenci();
o.OkulNo = int.Parse(textBox1.Text);
o.Ad = textBox2.Text;
o.Soyad = textBox3.Text;
o.Sinif = textBox4.Text;
o.Il = textBox5.Text;
o.Ilce = textBox6.Text;
o.EPosta = textBox7.Text;

oList.Add(o);
dataGridView1.DataSource = oList.ToList();
Kullanıcı avatarı
awr
Yönetici
Yönetici
Mesajlar: 3130
Kayıt: 31 Tem 2019 15:03
İletişim:

Dictionary

Mesaj gönderen awr »

Dictionary<string, Urun> uList = new Dictionary<string, Urun>();
private void button1_Click(object sender, EventArgs e)
{
string key = Guid.NewGuid().ToString();
Urun u = new Urun();
u.Cinsi = Convert.ToInt32(textBox1.Text);
u.Boy = Convert.ToInt32(textBox2.Text);
u.Yas = Convert.ToInt32(textBox3.Text);
u.Yogunluk = Convert.ToInt32(textBox4.Text);

uList.Add(key, u);
MessageBox.Show("Key : " + key + " kaydedildi");
dataGridView1.DataSource = uList.Values.ToList();
}
Yeni Başlık Cevapla

“Windows Form” sayfasına dön