Perform search in DataGridView using textbox c ++

0

Hi, I would like to know if someone can help me perform a search, in a DataGridView that from a TextBox when writing, that is, in the eventeo KeyPress the table will be refreshed to see the record.

As you can see in the image in textbox where it says Search: by entering for example the name bear that in the Datagridview only shows me that data of the three.

Note: I do not use a database, I keep the data in a txt file and I am using the IDE visual studio 2012 C ++ language

Thank you in advance, I would like you to do a search by name.

    
asked by Samuel Mena 10.05.2017 в 20:52
source

1 answer

1

What you should do in the KeyPress event is to iterate the rows of the DataGridView, looking for the corresponding value, and then perform the action you need.

in c ++ I would not know how to iterate, in C # it's something like

foreach(DataGridRow row in dgv1.Rows)
{
  if(row[1].value == stringabuscar)
  {
    row.SetSelected();
  }
}

I imagine it would be something similar but with a for up to the Length of dgv1.Rows.

All this assuming that the name of your DataGridView is dgv1

Sorry for syntax errors, it's been a long time since I programmed in .Net

    
answered by 10.05.2017 в 23:18