DataSource


Örnek
DataSource
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 WindowsFormsApp16
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] Pdiller = { "C#", "Java", "Python", "Delphi"};
            listBox1.DataSource = Pdiller;
            
            /*foreach (string D in Pdiller)
            {
                listBox1.Items.Add(D);
            }*/
        }
    }
}
 
Örnek
DataSource
using System;
using System.Collections.Generic;
using System.Text;

namespace OsmanKaraosman_U_63
{
    internal class RandevuVeri
    {
        public int Sira { get; set; }
        public string Bolum { get; set; }
    }
}
 
 
 
using System.Collections;

namespace OsmanKaraosman_U_63
{
    public partial class Form1 : Form
    {
        List<RandevuVeri> RVLIST = new List<RandevuVeri>();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                RandevuVeri RV = new RandevuVeri();
                RV.Sira = int.Parse(textBox1.Text);
                RV.Bolum = textBox2.Text;
                RVLIST.Add(RV);
                MessageBox.Show("Randevu Alındı", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Bagla();
                Listele();
            }
            catch { MessageBox.Show("Lütfen Belirtilmiş Alanları Doğru Giriniz"); }
        }
        public void Bagla()
        {
            comboBox1.SelectedIndexChanged -= comboBox1_SelectedIndexChanged;

            comboBox1.DataSource = null;
            comboBox1.DataSource = RVLIST;
            comboBox1.DisplayMember = "Bolum";
            comboBox1.ValueMember = "Sira";
        
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem is RandevuVeri secilen)
            {
                MessageBox.Show($"Randevülern Sıra:{secilen.Sira.ToString()}");
            }
        }
        public void Listele()
        {
            listView1.Items.Clear();

            foreach (var m in RVLIST)
            {
                listView1.Items.Add(new ListViewItem(new string[]
                {
            m.Bolum,
            m.Sira.ToString()
                }));
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listView1.Columns.Add("Bölüm", 75);
            listView1.Columns.Add("Sıra", 75);
        }
    }
}

 Osman KARAOSMAN

Örnek
DataSource
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;
using static System.Windows.Forms.LinkLabel;

namespace WindowsFormsApp17
{
    public partial class Form1 : Form
    {
        class Ogrenciler
        {
            public int Numara { get; set; }
            public string AdSoyad { get; set; }
            public int DersNotu { get; set; }
        }

        List<Ogrenciler> liste = new List<Ogrenciler>();

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_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();
        }

        private void Bagla()
        {
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = liste;
        }

        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
        }

        private void dataGridView1_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
DataSource
 
 
using System.Data;

namespace Uygulama
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        DataTable tablo = new DataTable();

        private void Form1_Load(object sender, EventArgs e)
        {
            tablo.Columns.Add("Numara", typeof(int));
            tablo.Columns.Add("Ad Soyad", typeof(string));
            tablo.Columns.Add("Not", typeof(int));
        }

        private void button1_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");
            }
        }

        public void Bagla()
        {
            gridListe.DataSource = tablo;
        }

        private void button3_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();
        }

        private void buttonHigh_Click(object sender, EventArgs e)
        {
            if (Ogrenciler.OGV.Count > 0)
            {
                BilgiGor BG = new BilgiGor();
                BG.ShowDialog();
            }
            else
            {
                MessageBox.Show("Sisteme Kayıtlı Öğrenci Yok");
            }
        }

        private void buttonLow_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;

namespace Uygulama
{
    internal class OgrenciVeri
    {
        public int Numarasi {  get; set; }
        public string AdiSoyAdi {  get; set; }
        public int Notu {  get; set; }
    }
    class Ogrenciler
    {
        public static List<OgrenciVeri> OGV = new List<OgrenciVeri>();
    }
}
 
enKucukForm.cs BilgiGor.cs
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Uygulama
{
    public partial class BilgiGor : Form
    {
        public BilgiGor()
        {
            InitializeComponent();
        }

        private void BilgiGor_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 };

        }
    }
}
 

Yükleniyor...

Yükleniyor...