validationdevexpressdatasourcegridcontrol

Validating cells in DevExpress GridControl


Just a simple question I can't manage myself.

I have a DevExpress GridControl for Winforms (12.2) filled with some numeric values, the grid is editable and the user can change those values.

Imagine the user changes one, what I want is to validate this cell in order to get the corresponding value modified in my datasource without clicking aoutside the cell.

That is to say, I want the user to be able to validate and apply all the values just pressing a button in a toolbar, not clicking enter, esc or clicking in the table.

I was looking some forums and didn't get the correct answer

Thanks,


Solution

  • In you handler for the menuItem_click do someething like this:

    private menuItem_Click(object sender, EventArgs e)
    {
      gridView1.UpdateCurrentRow(); //return a bool, false = if validation error(s) was found
    }
    

    This forces the view to validate input and push it down to the datasource.