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;
namespaceWindowsFormsApp16
{
publicpartialclassForm1 : Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidbutton1_Click(object sender, EventArgs e)
{
string[] Pdiller = { "C#", "Java", "Python", "Delphi"};
listBox1.DataSource = Pdiller;
/*foreach (string D in Pdiller)
{
listBox1.Items.Add(D);
}*/
}
}
}
Örnek
using System;
using System.Collections.Generic;
using System.Text;
namespaceOsmanKaraosman_U_63
{
internalclassRandevuVeri
{
publicint Sira { get; set; }
publicstring Bolum { get; set; }
}
}
using System;
using System.Collections;
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;
usingstatic System.Windows.Forms.LinkLabel;
namespaceWindowsFormsApp17
{
publicpartialclassForm1 : Form
{
classOgrenciler
{
publicint Numara { get; set; }
publicstring AdSoyad { get; set; }
publicint DersNotu { get; set; }
}
List<Ogrenciler> liste = new List<Ogrenciler>();
publicForm1()
{
InitializeComponent();
}
privatevoidbutton1_Click(object sender, EventArgs e)
{
Ogrenciler ogrenci = new Ogrenciler();
ogrenci.Numara = int.Parse(textBox1.Text);
ogrenci.AdSoyad = textBox2.Text;
ogrenci.DersNotu = int.Parse(textBox3.Text);
liste.Add(ogrenci);
textBox1.Text = textBox2.Text = textBox3.Text = "";
Bagla();
}
privatevoidBagla()
{
dataGridView1.DataSource = null;
dataGridView1.DataSource = liste;
}
privatevoiddataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
}
privatevoiddataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
textBox2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
textBox3.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
}
}
}
Örnek
using System.Data;
namespaceUygulama
{
publicpartialclassForm1 : Form
{
publicForm1()
{
InitializeComponent();
}
DataTable tablo = new DataTable();privatevoidForm1_Load(object sender, EventArgs e)
{
tablo.Columns.Add("Numara", typeof(int));
tablo.Columns.Add("Ad Soyad", typeof(string));
tablo.Columns.Add("Not", typeof(int));
}
privatevoidbutton1_Click(object sender, EventArgs e)
{
try
{
OgrenciVeri OG = new OgrenciVeri();
OG.Notu = Convert.ToInt32(textBoxNote.Text);
OG.Numarasi = Convert.ToInt32(textBoxNumara.Text);
OG.AdiSoyAdi = textBoxAdSoyad.Text;
if (OG.Notu > 100)
{
MessageBox.Show("100'den Fazla nt girilmez");
return;
}
Ogrenciler.OGV.Add(OG);
tablo.Rows.Add(OG.Numarasi, OG.AdiSoyAdi, OG.Notu);
Bagla();
}
catch
{
MessageBox.Show("Lütfen Geçerli Değer Girişi Yapınız");
}
}
publicvoidBagla()
{
gridListe.DataSource = tablo;
}
privatevoidbutton3_Click(object sender, EventArgs e)
{
Form yeniForm = new Form();
yeniForm.Text = "Aranan Öğrenciler";
yeniForm.Size = new Size(500, 300);
DataGridView aranan = new DataGridView();
aranan.Size = new Size(400, 200);
yeniForm.Controls.Add(aranan);
List<OgrenciVeri> bulunanlar = new List<OgrenciVeri>();
foreach (var m in Ogrenciler.OGV)
{
if (m.AdiSoyAdi == textBoxAra.Text)
{
MessageBox.Show($"{m.AdiSoyAdi} öğrencisi bulundunNotu: {m.Notu}nNumarası: {m.Numarasi}");
bulunanlar.Add(m);
}
}
if (bulunanlar.Count > 0)
{
aranan.DataSource = null;
aranan.DataSource = bulunanlar;
}
yeniForm.ShowDialog();
}
privatevoidbuttonHigh_Click(object sender, EventArgs e)
{
if (Ogrenciler.OGV.Count > 0)
{
BilgiGor BG = new BilgiGor();
BG.ShowDialog();
}
else
{
MessageBox.Show("Sisteme Kayıtlı Öğrenci Yok");
}
}
privatevoidbuttonLow_Click(object sender, EventArgs e)
{
if (Ogrenciler.OGV.Count > 0)
{
EnKucukForm ENK = new EnKucukForm();
ENK.ShowDialog();
}
}
}
}
OgrenciVeri.cs
using System;
using System.Collections.Generic;
using System.Text;
namespaceUygulama
{
internalclassOgrenciVeri
{
publicint Numarasi { get; set; }
publicstring AdiSoyAdi { get; set; }
publicint Notu { get; set; }
}
classOgrenciler
{
publicstatic List<OgrenciVeri> OGV = new List<OgrenciVeri>();
}
}
enKucukForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespaceUygulama
{
publicpartialclassEnKucukForm : Form
{
publicEnKucukForm()
{
InitializeComponent();
}
privatevoidEnKucukForm_Load(object sender, EventArgs e)
{
OgrenciVeri enKucuk = Ogrenciler.OGV[0];
foreach (var m in Ogrenciler.OGV)
{
if (m.Notu < enKucuk.Notu)
{
enKucuk = m;
}
}
dataGridView1.DataSource = null;
dataGridView1.DataSource = new List<OgrenciVeri> { enKucuk };
}
}
}
BilgiGor.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespaceUygulama
{
publicpartialclassBilgiGor : Form
{
publicBilgiGor()
{
InitializeComponent();
}
privatevoidBilgiGor_Load(object sender, EventArgs e)
{
OgrenciVeri enBuyuk = Ogrenciler.OGV[0];
foreach (var m in Ogrenciler.OGV)
{
if (m.Notu > enBuyuk.Notu)
{
enBuyuk = m;
}
}
dataGridView1.DataSource = null;
dataGridView1.DataSource = new List<OgrenciVeri> { enBuyuk };
}
}
}