public void RemoveDuplicate(DataGridView grv)
{
for (int currentRow = 0; currentRow < grv.Rows.Count - 1; currentRow++)
{
DataGridViewRow rowToCompare = grv.Rows[currentRow];
for (int otherRow = currentRow + 1; otherRow < grv.Rows.Count; otherRow++)
{
DataGridViewRow row = grv.Rows[otherRow];
bool duplicateRow = true;
for (int cellIndex = 0; cellIndex < row.Cells.Count; cellIndex++)
{
if (!rowToCompare.Cells[cellIndex].Value.Equals(row.Cells[cellIndex].Value))
{
duplicateRow = false;
break;
}
}
if (duplicateRow)
{
grv.Rows.Remove(row);
otherRow--;
}
}
}
}
{
for (int currentRow = 0; currentRow < grv.Rows.Count - 1; currentRow++)
{
DataGridViewRow rowToCompare = grv.Rows[currentRow];
for (int otherRow = currentRow + 1; otherRow < grv.Rows.Count; otherRow++)
{
DataGridViewRow row = grv.Rows[otherRow];
bool duplicateRow = true;
for (int cellIndex = 0; cellIndex < row.Cells.Count; cellIndex++)
{
if (!rowToCompare.Cells[cellIndex].Value.Equals(row.Cells[cellIndex].Value))
{
duplicateRow = false;
break;
}
}
if (duplicateRow)
{
grv.Rows.Remove(row);
otherRow--;
}
}
}
}