Hello DevExpress team,
we need a custom RichEdit control extension for our solution and we have a small problem with it. Please see solution attached, it is built on base of your samples and describes our question. We use property RichEditUserControl.RtfText (RichEditUserControl.cs line 20) as control binding property (RichEditPropertyEditor.cs line 14). I detected, that this property by new object is always initialized with an empty string, but not with null (just put a breakpoint in its setter and control the value). I think, it's not quite correct. In our real soultion we have a problem, because the corresponding business object property is set to null and the editor value is String.Empty, so they are not equals and the business object is marked as modified... Could you please take a look on it?
Best regards, Kim Schmidt
I have researched this behavior and found that it is not specific to the RichEditControl. Place a System.Windows.Forms.TextBox control to a standard form, set a breakpoint to its Text property, and you will see that this property is also set to an empty string when the control's data bindings are initialized.
You have mentioned that there is an issue with the object's modified state when the rich editor is used. It occurs because of specifics of the RTF format - an empty string can be represented by a non-empty RTF text that stores the default formatting settings. To avoid the object's modification in this case, you can set the Document.Text property to the default RtfText value initially, when the object is created. Alternatively, modify the RichEditUserControl.RtfText property so that it returns the null value or an empty string when the RichEditControl.RtfText property returns the default value.