I want to put the search option in DataGridView, i.e. the user enters a string or int in TextBoxand similar entries DataGridView. I tried to use this event KeyPressbut did not work.
if (Char.IsLetter(e.KeyChar))
{
for (int i = 0; i < (dgemployee.Rows.Count); i++)
{
if (dgemployee.Rows[i].Cells["Employee"].Value.ToString().
StartsWith(e.KeyChar.ToString(), true,
CultureInfo.InvariantCulture))
{
dgemployee.Rows[i].Cells[0].Selected = true;
return;
}
}
Actually, I need to search for everything DataGridView, not just one column and row. So, any better solution?
source
share