0

I have this Repository Item comboboxEdit in a Devexpress CustomGridView.

private void gridView1_CustomRowCellEditForEditing(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
 if (e.Column == this.gcCol1)
    {
        var repositoryItem = new RepositoryItemComboBox();
        foreach (var title in this.ViewModelList.Titles)
            {
                repositoryItem.Items.Add(title.TitleName);
            }
            repositoryItem.EditValueChanged += this.PostEditValueChanged;
            repositoryItem.Validating+=this.validating;
            e.RepositoryItem = repositoryItem;
    }
}
private void PostEditValueChanged(object sender, EventArgs e)
{
     this.gridView1.PostEditor();

}

EditValueChanged fires many times while typing. Is there a way to fire this EditValueChanged once after the user has completely finished editing the cell. Something along these lines http://www.devexpress.com/Support/Center/Question/Details/Q288616 Devexpress Support had some fix for this problem but didn't seem to help. Not sure why the activeedior is closing and resetting the cursor. I don't want to be setting the caret position in EditValueChanged.

I also tried CellvalueChanged but this would require a click in the usercontrol. Same with repository.validating

 repositoryItem.EditValueChanged += this.PostEditValueChanged;
 repositoryItem.Validating+=this.validating;

Is there a way to figure out if the user is done or still editing the combox box and then fire the editvaluechanged without having to worrying out clicks outside the combo box edit

user575219
  • 2,346
  • 15
  • 54
  • 105
  • EditValueChanged actually fires everytime the Edit Value changes at all, which means each new or deleted character will trigger the event. – ChargerIIC Aug 25 '14 at 18:03
  • I have a Posteditor in the editvalue changed event. The PostEditor() saves the changes to the datasource by not closing the active editor. But for some reason it was closing the active editor, meaning resetting the cursor to 0. So all I could do is not call the editvalueChanged when the user is making an Edit or Typing. But use the Validate when focus is lost – user575219 Aug 25 '14 at 20:08

3 Answers3

0

I was able to resolve this issue by not firing the EditvalueChanged and using the Validating event. This event fires when the editor is about to lose focus. Its unlike CellvalueChanged where if the user clicks on the form and not on the usercontrol, the change is lost.

user575219
  • 2,346
  • 15
  • 54
  • 105
0

gridView1.PostEditor(); will show the editor after populating the values. Similarly, We can change the validating event to fire on 'Enter Key' to resolve as a quick fix.

YReddy
  • 36
  • 2
0

A better approach:

Handle the GridView's CellValueChanged event, rather than EditValueChanged on the editor.

In the handler, determine which column fired the event. For example,

if (e.Column.Equals(this.gvColTitle))
{
    //Access the repository item:
    ComboBoxEdit editor = this.gridView1.ActiveEditor as ComboBoxEdit;  

    //Assign your values to the editor.
}

I'm not sure why you're adding the repository item at runtime, but you may be able to just create it in the XtraGrid Designer screen, and assign it to the column there. You can still update its item list at runtime using the above.

Bryan H.
  • 26
  • 3