Siempre me pasa eso porque tiene un monton de cosas.
Pero fijate si no es el RowValidating
Aca unos ejemplos que encontre:
Código:
private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
bool bHaveError = false;
string sErrorMsg_RequiredFields = string.Empty;
int newInteger;
if (this.dataGridView1.IsCurrentRowDirty)
{
System.Windows.Forms.DataGridViewRow oDGVR = this.dataGridView1.Rows[e.RowIndex];
if (oDGVR.Cells["FirstName"].Value.ToString().Trim().Length < 1)
{
sErrorMsg_RequiredFields += " First name is required." + Environment.NewLine;
bHaveError = true;
}
if (oDGVR.Cells["Age"].Value.ToString().Trim().Length < 1)
{
sErrorMsg_RequiredFields += " Age is required." + Environment.NewLine;
bHaveError = true;
}
else if (!int.TryParse(oDGVR.Cells["Age"].Value.ToString(), out newInteger) || newInteger < 0)
{
sErrorMsg_RequiredFields += " Age must be a number." + Environment.NewLine;
bHaveError = true;
}
if (oDGVR.Cells["IsActive"].Value.ToString() == string.Empty)
{
sErrorMsg_RequiredFields += " Active Status is required." + Environment.NewLine;
bHaveError = true;
}
if (bHaveError)
{
oDGVR.ErrorText = sErrorMsg_RequiredFields;
e.Cancel = true;
}
}
}
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
int newInteger;
this.dataGridView1.Rows[e.RowIndex].ErrorText = "";
// No cell validation for new rows. New rows are validated on Row Validation.
if (this.dataGridView1.Rows[e.RowIndex].IsNewRow) { return; }
if (this.dataGridView1.IsCurrentCellDirty)
{
switch (this.dataGridView1.Columns[e.ColumnIndex].Name)
{
case "FirstName":
if (e.FormattedValue.ToString().Trim().Length < 1)
{
e.Cancel = true;
this.dataGridView1.Rows[e.RowIndex].ErrorText = " First name is required.";
}
break;
case "Age":
if (e.FormattedValue.ToString().Trim().Length < 1)
{
e.Cancel = true;
this.dataGridView1.Rows[e.RowIndex].ErrorText = " Age is required.";
}
else if (!int.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger < 0)
{
e.Cancel = true;
this.dataGridView1.Rows[e.RowIndex].ErrorText = " Age must be a positive number.";
}
break;
case "IsActive":
if ((CheckState) e.FormattedValue == CheckState.Indeterminate)
{
e.Cancel = true;
this.dataGridViewSection.Rows[e.RowIndex].ErrorText = " Active status is required.";
}
break;
}
}
}
Lo saqué de acá:
http://www.forosdelweb.com/newreply....reply&t=686444
Suerte!!!