I want to make a search list using datagridview in c#. I have a text box where one can enter the customer name. When the "search" button is clicked, i will hide all the rows where the CustomerName is not equal to the searchValue. The problem is that when the user want to search for the second time, how can I search through the hidden rows of the dgv. Do i need to make visible the rows hidden. Thanks.
Here is the Code.
private void search_Click(object sender, EventArgs e)
{
arrayList= new ArrayList();
String searchValue = searchBox.Text;
for (int i = 0; i < dataGridView1.RowCount-1; i++)
{
if ( (dataGridView1.Rows[i].Cells[1].Value.ToString().Trim() ).Equals (searchValue.Trim()) )
{
//dataGridView1.Visible = true;
arrayList.Add(i);
}
else
{
dataGridView1.Visible = false;
}
}
dataGridView1.Refresh();
}