2
votes

There are 2 distinct UI concept: CellValueChanging vs CellValueChanged.

Quoted from DevExpress Documentation:

The CellValueChanging event is raised each time the edited value is being changed (the user types or deletes a character, chooses a value from the dropdown list, etc.).

On the other hand, CellValueChanged is raised when user had done cell editing by hitting enter or clicking outside of the active cell.

Now my problem is, I have a combobox type column, and I want to always skip the CellValueChanging and make the change final. The current behavior is when user select an item from the combobox, the change doesn't take effect immediately(e.g, the view will not be resorted as per the change). The change is not accepted until user hit enter or click outside of the cell.

---------------07/26/2013 2:25PM update---------------
Sorry that my previous question description misled everybody, so I'll rephrase it.

Here is the current behavior:

Pic1: beginning state. Rows are sorted alphabetically by Target.
enter image description here

Pic2: Change the 2nd row value from B to D
enter image description here

Pic3: After a single mouse left click on item D, the dropdown disappears and the cell value changes to D. However, the rows are not resorted
enter image description here

Pic4: After clicking outside the cell or hitting enter, the rows are resorted.
enter image description here

What I want to achieve is to skip the step in Pic3. In other word, I want any changes committed immediately, without having to make an extra kepboard or mouse click.

What I am showing here is a simplified example of my application. I can't move my CellValueChanged event handler logic to CellValueChanging or EditValueChanged because it would cause some errors.

2
What is your exact question you want to Update to datasource immediately?Sriram Sakthivel
Yes that's what I was asking...GoCurry
Check my answer if that helps youSriram Sakthivel

2 Answers

1
votes

You want to make some UI change once user edit the cell value, right? I think generally you have to give up handling the CellValueChanged event, but use the CellValueChanging Event instead:

pseudocode:

HandleCellValueChanging(object sender, CellValueChangingEventArgs e) 
{
   // Get underlying object
   // and write the value direct into the object
   var rowObj = (YourType)gridview.GetRow(gridView.FocusedRowHandle);
   rowObj.TargetField = e.NewValue; // e.Value or e.NewValue, not sure

   // Then Do your UI effect
}

Another option is to use RepositoryItemEditor and handle the key-up and/or Mouse-up event instead.

1
votes

If you want to to catch the moment when an end-user changes some value in gridview's cell editor (e.g. select item in combobox), please handle the EditValueChanged event of a corresponding RepositoryItem. To immediately post this value (make the changes final), you need to call the PostEditor method of a corresponding container:

repositoryItemComboBox1.EditValueChanged += repositoryItemComboBox1_EditValueChanged;
//...
void repositoryItemComboBox1_EditValueChanged(object sender, EventArgs e) {
    gridView1.PostEditor();
    // do something else if it needed
}

Related example: E3234 - How to update a row's style immediately after a an inplace editor's value is changed