Hello!
I have this method below that use a for loop to remove a DataRow from a
DataTable.
I have a DataGridView that is named dgvStock
I have a DataTable that is named _dataTable
I just wonder if it's possible to remove the for loop and
use a foreach loop insted but it might be problem because of the index into
dgvStock.
private void DeleteRedRow()
{
//Loop through all DataRow in the DataTable
for(int i = 0; i < _dataTable.Rows.Count; i++)
{
if (dgvStock.Rows[i].DefaultCellStyle.BackColor ==
System.Drawing.Color.Red)
{
_dataTable.Rows[i].AcceptChanges();
_dataTable.Rows[i].Delete();
}
}
}
//Tony
|