this method check the already added product in the datagrid
if the product exist then method return false , else return true....
public bool Check_Product_Exists()
{
bool result = true;
string product = "";
for (int b = 0; b < grd_dtls.Rows.Count - 1; b++)
{
for (int c = 0; c < grd_dtls.Rows.Count - 1; c++)
{
if (c != b)
{
if (product.Equals(grd_dtls.Rows[c].Cells[0].Value))
{
grd_dtls.Rows[c].Selected = true;
MessageBox.Show("You have selected a product twice.");
return result = false;
}
}
}
}
return result;
}
use this code put your grid name instead of mine