4

How to get the currently edited value when handling the:

public class GridEX // ...
{
    // ... 
    public event ColumnActionEventHandler CellValueChanged;
    // ...
};

Trying to obtain the value using:

GridEXCell valueChangedCell = _gridView.CurrentRow.Cells[<desired_column_index>];
object rawValue = valueChangedCell.Value;
// or even with
string rawValue = valueChangedCell.Text;

The only moment at which the valueChangedCell has its value changed is when either the CellUpdated or the UpdatingCell event is fired. But the latter two are fired only in case the user has changed the keyboard input focus to another cell probably for the sake of applying the edited cell's new value. The cell I want to lookup the value of is one containing only a checkbox. I want to perform a given action immediately after the checkbox of a given cell is toggled, not as soon as the user changes the focus e.g. moves to another cell in the table. Saw that in the descriptions of the events some row buffer is mentioned:

[Description("Occurs after changes in a cell are copied into the row's buffer.")]
public event ColumnActionEventHandler CellUpdated;

[Description("Occurs before updating the changes in a cell to the row's buffer")]
public event UpdatingCellEventHandler UpdatingCell;

I presume that the current value of the checkbox is probably kept in some buffer and upon changing the focus the new value is applied to the cell.

Any ideas how to fetch the currently set value of the checkbox upon handling the Janus' GridEX.CellValueChanged?

TodorBalabanski
  • 109
  • 2
  • 10

2 Answers2

4

I fixed the problem adding a method which is firing within the event below: private void

CloseEditMode() 
{ 
   gridRubrica.AllowEdit = InheritableBoolean.False; 
   gridRubrica.AllowEdit = InheritableBoolean.True; 
} 

private void gridRubrica_CellValueUpdated(object sender, ColumnActionEventArgs e) 
{ 
   if (e.Column.Key.Equals("Selected")) { CloseEditMode(); } 
} 
TodorBalabanski
  • 109
  • 2
  • 10
1

A little bit late to the party, but since I was having the same difficulty I decided to just flush the pending changes when the Cell Changed is a CheckBox

private void gridEX1_CellChanged(object sender, ColumnActionEventArgs e)
{
    if (e.Column.ColumnType == ColumnType.CheckBox)
    {
        gridEX1.UpdateData(); // Flush any pending changes
    }
}

This will trigger the other handler that deals with validation (in my case)

gtgaxiola
  • 9,241
  • 5
  • 42
  • 64
  • 2
    This doesn't work for me, because when you don't change the focus of the row that you are updating, the model is not updated. I fixed the problem adding a method which is firing within the event below: private void CloseEditMode() { gridRubrica.AllowEdit = InheritableBoolean.False; gridRubrica.AllowEdit = InheritableBoolean.True; } private void gridRubrica_CellValueUpdated(object sender, ColumnActionEventArgs e) { if (e.Column.Key.Equals("Selected")) { CloseEditMode(); } } – TodorBalabanski Dec 08 '16 at 13:17
  • 2
    LOL! I just had this problem once more and I found my own solution! Thank you Past ME! – gtgaxiola Mar 19 '18 at 20:26