Data Grid View

Data Grid View

private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.ColumnCount = 5;  //Kaç tana stun olduğunu belirtiyor //
            dataGridView1.Columns[0].Name = "Sıra No";   //Kaçıncı indis srıra İsmi
            dataGridView1.Columns[1].Name = "Adı";
            dataGridView1.Columns[2].Name = "Soyadı";
            dataGridView1.Columns[3].Name = "Meslek";
            dataGridView1.Columns[4].Name = "Şehir";
        }
 private void button1_Click(object sender, EventArgs e)
        {
            int i = dataGridView1.Rows.Add(3);

            i = 0;
            dataGridView1.Rows[i].Cells[0].Value = 1;
            dataGridView1.Rows[i].Cells[1].Value = "Cihan";
            dataGridView1.Rows[i].Cells[2].Value = "Çallı";
            dataGridView1.Rows[i].Cells[3].Value = "Öğrenci";
            dataGridView1.Rows[i].Cells[4].Value = "Malatya";

            
i = 1;
            dataGridView1.Rows[i].Cells[0].Value = textBox1.Text;
            dataGridView1.Rows[i].Cells[1].Value = textBox2.Text;
            dataGridView1.Rows[i].Cells[2].Value = textBox3.Text;
            dataGridView1.Rows[i].Cells[3].Value = textBox4.Text;
            dataGridView1.Rows[i].Cells[4].Value = comboBox1.Text;
        }
Time vector created by slidesgo – www.freepik.com

Leave a Reply