2 formdan oluşuyor dikkat edin
Arama motoru formu 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
SqlConnection conn;
SqlCommand cmd;
SqlDataAdapter da;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2(this);
f.ShowDialog();
}
public void AramaYap(string aranan, string alan)
{
DataView v = new DataView(ds.Tables["musteriler"]);
v.RowFilter = " " + alan + " LIKE '" + aranan + "%' ";
dataGridView1.DataSource = v;
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection();
conn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\ticaret.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
conn.Open();
cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM musteriler";
cmd.Connection = conn;
da = new SqlDataAdapter();
da.SelectCommand = cmd;
ds = new DataSet();
da.Fill(ds, "musteriler");
dataGridView1.DataSource = ds.Tables["musteriler"];
}
}
}
// Arama motoru formu 2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form2 : Form
{
Form1 anaForm;
public Form2(Form1 form)
{
anaForm = form;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
anaForm.AramaYap(textBox1.Text, comboBox1.SelectedItem.ToString());
Close();
}
}
}