Hello. There are 2 DataGridView in only one date, and in the second date and many other columns. It is necessary when you click on 1 DataGridView on the date all data on the selected date was displayed in 2 DataGridView. What am I doing wrong?

private void Planavimas_DataSet_Load(object sender, EventArgs e) { // TODO: данная строка кода позволяет загрузить данные в таблицу "pard_planasDataSet.Pardavimo_men". При необходимости она может быть перемещена или удалена. this.pardavimo_menTableAdapter.Fill(this.pard_planasDataSet.Pardavimo_men); // TODO: данная строка кода позволяет загрузить данные в таблицу "pard_planasDataSet.Plan_prekes". При необходимости она может быть перемещена или удалена. this.plan_prekesTableAdapter.Fill(this.pard_planasDataSet.Plan_prekes); planprekesBindingSource.Sort = "Pavadinimas ASC"; } private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[1].Value == null) { planprekesBindingSource.Filter = string.Empty; } else planprekesBindingSource.Filter = string.Format("[Data] Like'" + dataGridView1.Rows[i].Cells[1].Value + "%'"); } } 
  • I will try, but I'm not sure that I will have access to the computer, until tomorrow morning - Alexander Muksimov
  • @ Alexander Muksimov I will wait :) - Vadim

1 answer 1

That solved the problem:

 for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == null) { planprekesBindingSource.Filter = string.Empty; } else planprekesBindingSource.Filter = string.Format("[Data] Like'" + dataGridView1.Rows[e.RowIndex].Cells[1].Value + "%'"); } 

And what should the string look like if you need several filters at the same time. for example, is there one that is now and + a filter with a textbox and another one with a combobox?