Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • 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?
                                    Thank you.
                                    Best regards, Kim Schmidt

                                Solution9.zip
                                • Hello Kim,

                                  I am forwarding this ticket to our XAF team so that they can take a look at it. As for a standalone RichEditControl, its RtfText property isn't initialized with an empty string. This property contains RTF that describes default formatting. The Text property is an empty string, but we consider this behavior correct.

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hello Kim,

                                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.

                                • Kim_Schmidt 12.06.2013

                                  Hello Anatol,

                                  thank you for explanation.

                                  > 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.
                                  This is exactly my problem. I have to differentiate between empty string and null value. Do i have any chance to find out from RichEditUserControl what is the value of the corresponding business object property?
                                  Thank you.
                                  Best regards, Kim Schmidt.

                                • Kim_Schmidt 12.06.2013

                                  Hallo Anatol,

                                  another one thing regarding to this problem. With solution above, please open DetailView with new one object and click "Validata" action. You'll get validation error, as expected. Now click somewhere on the RTF document and click "Validate" again - validation succeeded. My oppinion - it's not quite correct, beuase, there is no any real content in the "_Text" property, it's only RTF-stuff. We need to validate the real text in our solution. Do you have any suggestions, how can we do it?
                                  Thank you and have a nice weekend.
                                  Best regards, Kim Schmidt

                                • You can obtain the business object to which your control is bound via its DataBindings collection. For example:

                                  [C#]
                                  object obj = richEditControl.DataBindings["RtfText"].DataSource;
                                  Hope this will help.

                                  >> We need to validate the real text in our solution.

                                  The RuleRequiredField rule cannot work with the RTF text. As I mentioned, an empty value can be represented by a non-empty string in the RTF format. The rule should take this into account. It appears that in your case, it is better to implement a custom rule. Alternatively, create separate properties for the RTF and plain texts, and perform operations specific to the plain text with the plain text property.

                                • Kim_Schmidt 12.11.2013

                                  Hello Anatol,
                                  thank you very much for your assistance. Now it works almost fine, just one question (hope, the last one for this subject) - if the validation fails, the rich-text field is not highlighted (the red sign does not appear). You can check is also with solution above. I've checked it both with default rich text editor and with our extension - the highlight does not appear in both cases. Also, i've checked it with "RuleRequiredField" and "RuleFromBoolProperty with UsedProperties = MyRtfField" - the same problem. Do i something wrong or is it an issue?
                                  Thank you.
                                  Best regards, Kim Schmidt.

                                • By default, the error icon appears only for controls inherited from the BaseEdit class. RichEditControl cannot display the error icon itself. To display this icon, you can use the ErrorProvider component, as shown in the Validation in richedit ticket. Add this component to your user control, then override the property editor's ErrorIcon and ErrorMessage properties and utilize the ErrorProvider in their setters. Let me know if you have any difficulties with this.

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners