Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1.         private void CheckChanges(DataGridView view0, DataGridView view1)
  2.         {
  3.             if (view0.RowCount < 1 || view1.RowCount < 1)
  4.                 throw new Exception("Файлы должны быть не пусты");
  5.  
  6.             var max = view0.RowCount > view1.RowCount ? view0.RowCount : view1.RowCount;
  7.  
  8.             for (int i = 0; i < max; i++)
  9.                 CompareCells(view0.Rows[i], view1.Rows[i]);
  10.         }
  11.  
  12.         private void CompareCells(DataGridViewRow row0, DataGridViewRow row1)
  13.         {
  14.             if (row0.Cells.Count < 1 || row1.Cells.Count < 1)
  15.                 throw new Exception("Файлы должны быть не пусты");
  16.  
  17.             var max = row0.Cells.Count > row1.Cells.Count ? row0.Cells.Count : row1.Cells.Count;
  18.  
  19.             for (int i =0;i<max; i++)
  20.             {
  21.                 var cell0 = row0.Cells[i];
  22.                 var cell1 = row1.Cells[i];
  23.                
  24.                 cell1.Style.BackColor = (string)cell0.Value != (string)cell1.Value ? Color.Red : Color.White;
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement