Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Search Record in DataGridView Through TextBox in C#.
(By Selection of column)

Like this:

i have one Form:

Form1(containing DataGridView And One TextBox).

i select the column in the datagridview, and search the record through textbox.



plz,plz,plz,plz, ANyone Can Help Me...
Posted
Comments
joshrduncan2012 31-Oct-12 9:44am    
Can you show us your code as to where you are right now? We won't do the work for you, but we can certainly help you if you are to a point in your code where you are stuck.

1 solution

You can filter the data but not sure about searching.

Here is how you can do..

private void dataGridView1_ColumnHeaderMouseDoubleClick(object sender, DataGridViewC....
{
//open filter dialog box
//Filter by criteria
}

See this page

http://stackoverflow.com/questions/5843537/filtering-datagridview-without-changing-datasource[^]

private void textBox1_TextChanged(object sender, EventArgs e)
{
MessageBox.Show("DataSource type BEFORE = " + dataGridView1.DataSource.GetType().ToString(), ds.Tables[0].DefaultView.Count.ToString());

DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = string.Format("country LIKE '%{0}%'", textBox1.Text);
dataGridView1.DataSource = dv;

MessageBox.Show("DataSource type AFTER = " + dataGridView1.DataSource.GetType().ToString(), ds.Tables[0].DefaultView.Count.ToString());
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900