Advertisement
kaizonaro

Search DataGridView

May 14th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1.  public static class Extensions
  2.     {
  3.         public static DataGridView SearchDataGrid(this DataGridView Grid, string Text = "")
  4.         {
  5.             foreach (DataGridViewRow linha in Grid.Rows)
  6.             {
  7.                 foreach (DataGridViewCell celula in linha.Cells)
  8.                 {
  9.                     if (string.IsNullOrWhiteSpace(Text) || celula.Value.ToString().Contains(Text))
  10.                     {
  11.                         linha.Visible = true;
  12.                         break;
  13.                     }
  14.                     linha.Visible = false;
  15.                 }
  16.             }
  17.             return Grid;
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement