This may be quite a common asked question with regards to the search results, however, I haven't yet found the answer to my problem.
I am loading 3 different types of DataGridView's in 3 different Pages (Window forms), and in each and every single one of them, previously viewed data rows are added onto it (the newly opened DataGridView).
Does anyone know of a way I can prevent this from happening?
private void Emp_Awaiting_Dispatch_Orders_Load(object sender, EventArgs e)
{
foreach (TBL_Order ord in DataLOrders.Get_Status_AwaitingDispatchOrder())
{
ViewAwaitDipOrd_DGV.Rows.Add(ord.OrderID, ord.CustomerID, ord.ProductID, ord.Status, ord.Quantity, "Switch to Dispatched");
}
}
private void ViewAwaitDipOrd_DGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (ViewAwaitDipOrd_DGV.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
{
if (e.ColumnIndex == 5)
{
BusinessLOrders.OrderDispatched();
foreach (TBL_Order ord in DataLOrders.Get_Status_AwaitingDispatchOrder())
{
Int32.TryParse(ViewAwaitDipOrd_DGV.Rows[e.RowIndex].Cells[0].FormattedValue.ToString(), out cellID);
if (ord.ProductID == cellID)
{
Int32.TryParse(ViewAwaitDipOrd_DGV.Rows[e.RowIndex].Cells[0].FormattedValue.ToString(), out cellID);
}
}
}
}
}