Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/04/2009, 11:36
Trulala de cordoba
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 24 años, 3 meses
Puntos: 19
Respuesta: Datagridview y evento después de actualizar

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!!!
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!