Click here to Skip to main content
16,020,741 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello Sir,


I have a text box in my form to show data by start character but it display all data including same character and my code is

private void TextBoxName_TextChanged(object sender, EventArgs e)

{


DataGridView.FilterName = TextBoxName.Text;
DataGridView.BindGrid();
}



and i write one letter in text box EXAMPLE:-i write
"A" in text box so the all data started character by "A" have to display
so i get data by order(by start Character) in my data grid view.So plz help me and solve my problem
Posted
Updated 10-May-10 19:12pm
v4

1 solution

If I correctly understand your problem, I'd recommend to use BindingSource and it's filter
public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
      MyDBDataSet ds = new MyDBDataSet();
      BindingSource bs ;

      private void Form1_Load(object sender, EventArgs e)
      {
          MyDBDataSetTableAdapters.ClientsTableAdapter adapter = new WindowsFormsApplication48.MyDBDataSetTableAdapters.ClientsTableAdapter();
          bs = new BindingSource(ds, "Clients");
          adapter.Fill(ds.Clients);
          this.dataGridView1.DataSource = bs;
      }

      private void textBox1_TextChanged(object sender, EventArgs e)
      {
          bs.Filter =String.Format("Customer like '%{0}%'",textBox1.Text);
      }
  }
 
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