N
N
Nikita Salnikov2020-05-12 15:10:43
C++ / C#
Nikita Salnikov, 2020-05-12 15:10:43

How to implement search (filtering) of data from the database by date?

hello. help me please. how to make it so that in a separate form for data search, when the user specifies a date in the dateTimePicker, the necessary dates are highlighted in the datagrid. I implemented a search by other parameters.
5eba921d65e48867392449.jpeg

private void SearchButton_Click(object sender, EventArgs e)
        {
            Form1 main = this.Owner as Form1;
            if (main != null)
            {
                for (int i = 0; i < main.dataGridView1.RowCount; i++)
                {
                    main.dataGridView1.Rows[i].Selected = false;
                    for (int j = 0; j < main.dataGridView1.RowCount; j++)
                        if (main.dataGridView1.Rows[i].Cells[j].Value != null)
                            if (main.dataGridView1.Rows[i].Cells[j].Value.ToString().Contains(tbStr.Text))
                            {
                                main.dataGridView1.Rows[i].Selected = true;
                                break;
                            }
                }
            }
        }

   private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
           
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question