Content search
The example demonstrates how to implement search for target values in .Net Grid. Just enter any numeric value into the Regular Expression textbox and target values that satisfy regular expression will be marked with orange color (if such values exist). Left/right buttons to the right of search textbox move the focus to the previous/next cell matching to the specified criteria.
The example uses a custom cell painting that can be easily implemented in the code – it should just handle grid’s Grid.PaintCell event and invalidate the grid client area by invoking grid.Invalidate() method every time user inputs values in the search textbox.

// Handling PaintCell event for the grid and attaching handler-method grid.PaintCell += grid_PaintCell; // Custom cell painting private void grid_PaintCell(object sender, PaintCellEventArgs e) { if (e.Cell.Text == txt_Search.Text) { e.Appearance.BackColor = Color.Orange; // custom back color } } // Handling TextBox’s TextChanged event and attaching handler-method txt_Search.TextChanged += txt_Search_TextChanged; // Repainting grid every time a user enters value in the search textbox private void txt_Search_TextChanged(object sender, EventArgs e) { grid.Invalidate(); }