Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/07/2010, 13:16
Avatar de Porlachucha
Porlachucha
 
Fecha de Ingreso: noviembre-2008
Ubicación: Santiago
Mensajes: 172
Antigüedad: 15 años, 5 meses
Puntos: 5
Respuesta: Editar celdas en un datagrid

lo mejor para esto, es usar el evento EditingControlShowing asociado al datagridview

Código:
        private void dgvMiDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            try
            {
                TextBox Tbx = e.Control as TextBox;
                ComboBox Cbx = e.Control as ComboBox;

                if (Cbx != null)
                {
                    Cbx.Validated -= new EventHandler(Cbx_ValidaIngresoComboBox);
                    Cbx.Validated += new EventHandler(Cbx_ValidaIngresoComboBox);
                }

                if (Tbx != null)
                {
                    Tbx.Validated -= new EventHandler(Tbx_ValidaIngresoTexto);
                    Tbx.Validated += new EventHandler(Tbx_ValidaIngresoTexto);
                }

            }
            catch (Exception)
            {
                throw;
            }
        }
luego te creas las funciones que validan los datos tanto del combobox como del textbox

Código:
        private void Tbx_ValidaIngresoTexto(object sender, EventArgs e)
        {
            try
            {
                #region Obtiene Valores
                string sValorVariable = ((TextBox)sender).Text.Trim();
                int iFilaEditada = dgvMiDataGridView.CurrentRow.Index;

                el resto de tu codigo....

             }
        }
Plch
__________________
Nada mas patetico que "detestar" a Intel o Microsoft o Windows o Apple ... apuesto que eres el tipico teton espinilluo y pajero que usa Linux para sentirse capo ...