DevExpress PropertyGridControl changes not detected using Ribbon button (by default)

TLDR; set CausesValidation to true on a ribbon bar button to make sure any controls that support validation, such as property grids, have their changes committed and validated before moving focus to the button.

I recently had a problem trying to verify data on a property grid – any changes I had just made, where the cursor was still active on the grid editor, were not committed when I clicked a ribbon bar button. For example, when my application starts it looks like this:

And when I click ‘Display person’ I get a message box:

However, if I change the ‘Age’ property and click the ‘Display person’ button without first hitting the enter key, I see this:

The DevExpress button click does not result in the changes being noticed before displaying the message box because the CausesValidation property is false:

Note that the built-in .Net Framework button has this property set to true by default.

Changing the property to true causes the property grid’s validation to be performed which includes attempting to commit any live changes to the underlying object, the Person instance.

And adding a message box to the property grid’s validating event makes the change and sequence of events more visible:

First:

Then:

Written this post because I figured this out about 2 years ago and today forgot everything !

Leave a comment