CellEditEnding event is fired TWICE when I hit TAB to exit the cell.

Oct 1, 2009 at 10:25 AM

Hi i have a issue  using the CellEditEnding event of the datagrid control.

I'm trying  to control the select change event in a combobox, to change some data in my item with this code

 

 private void GridMantenimiento_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (op == "SubTipoActividad")
            {
                ComboBox cb = e.EditingElement as ComboBox;
                if (cb != null)
                {
                    cod_tipoActividad = int.Parse(cb.SelectedValue.ToString());
                    ((sender as DataGrid).SelectedItem as subtipo_actividad).tipo_actividadReference.EntityKey = new EntityKey("fundacionEntities.tipo_actividad", "cod_tipo_actividad", cod_tipoActividad);
                }
            }
        }

 private void GridMantenimiento_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)

        {

            if (op == "SubTipoActividad")

            {

                ComboBox cb = e.EditingElement as ComboBox;

                if (cb != null)

                {

                    cod_tipoActividad = int.Parse(cb.SelectedValue.ToString());

                    ((sender as DataGrid).SelectedItem as subtipo_actividad).tipo_actividadReference.EntityKey = new EntityKey("fundacionEntities.tipo_actividad", "cod_tipo_actividad", cod_tipoActividad);

 

                }

            }

        }

 

i have two problem with this. the first problem i have is the event is rising twice when i use the tab key to leave the cell, one for the cell that i'm editing and another one for the next cell.

the second problem is the RowEditEnding is fire after the celleditending event, even when i only edit the first cell of the row.

 

If any one have a idea to solve this, i be very pleased  

Sorry if my English is not good