Merhaba arkadaşlar.Resimde görüldüğü üzere texboxt ile gridviewe gelen veriler için arama yapabiliyorum fakat comboBox a çektiğim verile ile gridview içinde arama,filtreleme yapamadım.Yardımcı olabilir misiniz ?
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Personel_Takip_Otomasyonu { public partial class frmPersonelListele : Form { public frmPersonelListele() { InitializeComponent(); }
private void YenileListele() { Veritabani.Listele_Ara(dataGridView1, "select p.PersonelID,p.Adi,p.Soyadi,p.Sicil,p.Telefon,d.Birim,p.Durumu,p.Aciklama from Personeller p, Departmanlar d where p.DepartmanID = d.DepartmanID"); lblToplamPersonel.Text = "Toplam " + (dataGridView1.Rows.Count - 1) + " Kayıt Listelendi.";
} void Temizle()
{
comboBirim.Text = ""; foreach (Control item in Controls) { if (item is TextBox) { item.Text = ""; } } } Personeller p = new Personeller(); Kullanicilar k = new Kullanicilar();
private void txtPersonelIDAra_TextChanged(object sender, EventArgs e) { Veritabani.Listele_Ara(dataGridView1,"select p.PersonelID,p.Adi,p.Soyadi,p.Sicil,p.Telefon,d.Departman,p.Durumu,p.Aciklama from Personeller p, Departmanlar d where p.DepartmanID = d.DepartmanID and PersonelID like '%"+txtPersonelIDAra.Text+"%'"); }
private void txtPersonelAdAra_TextChanged(object sender, EventArgs e) { Veritabani.Listele_Ara(dataGridView1, "select p.PersonelID,p.Adi,p.Soyadi,p.Sicil,p.Telefon,d.Departman,p.Durumu,p.Aciklama from Personeller p, Departmanlar d where p.DepartmanID = d.DepartmanID and Adi like '%" + txtPersonelAdAra.Text + "%'"); }
private void txtPersonelSoyadAra_TextChanged(object sender, EventArgs e) { Veritabani.Listele_Ara(dataGridView1, "select p.PersonelID,p.Adi,p.Soyadi,p.Sicil,p.Telefon,d.Departman,p.Durumu,p.Aciklama from Personeller p, Departmanlar d where p.DepartmanID = d.DepartmanID and Soyadi like '%" + txtPersonelSoyadAra.Text + "%'"); }
private void txtPersonelSicilAra_TextChanged(object sender, EventArgs e) { Veritabani.Listele_Ara(dataGridView1, "select p.PersonelID,p.Adi,p.Soyadi,p.Sicil,p.Telefon,d.Departman,p.Durumu,p.Aciklama from Personeller p, Departmanlar d where p.DepartmanID = d.DepartmanID and Sicil like '%" + txtPersonelSicilAra.Text + "%'"); }
textler çalışıyor ise eğer aynı şekilde combobox için yazacaksınız. Yani ; txtPersonelSicilAra.Text yazdığınız yere 'bomboboxAdi.selectedindex.text' gibi birşey olması lazım deneyemediğim için tam bilmiyorum.
< Resime gitmek için tıklayın >