private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (Your Validation) //Your custom validation { this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Error"; e.Cancel = true; //will prevent user from leaving cell, you can decide that yourself. } }
Thanks, Mahesh
public static bool CheckRowEmpty(DataGridView DGV) { if (DGV.Rows[0].Cells.Count > 0) { foreach (DataGridViewCell cell in DGV.Rows[0].Cells) { if (cell.Value != null) { rowIsEmpty = false; break; } else { rowIsEmpty = true; break; } } } return rowIsEmpty; }
if (CheckRowEmpty(datagridiview1)) { .ErrProvider.SetError(datagridiview1, "Please Fill Skills Information"); } else { ErrProvider.SetError(datagridiview1, ""); }
Regards, Lakshmi Naraayanan.S http://dotnettechrocks.blogspot.in/ http://abaprocker.blogspot.com/
Login to post response