 
 
DataGridView Nesnesinde Kayıt Arama
Merhaba arkadaşlar. Bu makalede DataGridView nesnesinde ilk ada göre arama yapılıp, kişinin işini mesaj olarak ekrana yazılmasını sağlayacağız.


Form1.cs
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'northwindDataSet1.Customers' table. You can move, or remove it, as needed.
            this.customersTableAdapter.Fill(this.northwindDataSet1.Customers);
        }
        private void btnAra_Click(object sender, EventArgs e)
        {
            string ara = textBox1.Text;
            int sonuc = 0;
            DataRow[] row;
            row = northwindDataSet1.Tables["Customers"].Select("FirstName='" + ara + "'");
            sonuc = row.Length;
            if (sonuc > 0)
            {
                DataRow dr;
                dr = row[0];
                dataGridView1.DataSource = row;
                MessageBox.Show(dr["FirstName"].ToString() + " in işi: " + dr["JobTitle"].ToString());
                               
                            }
                else
                {
                MessageBox.Show("Kayıt yok");
                }
            }
        }
    }
Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek dileğiyle. Hoşçakalın. Bahadır ŞAHİN