Good afternoon,
I have attached a sample which illustrates the issue I am having, which I will be referring to throughout this issue report.
In my exact case I am binding to the "HTMLText" property of two richeditcontrols on one form. However, the same symptoms occur when binding to the "Text" property also, and as this is probably more pertinent to more people I have set my example up to demonstrate with this property instead. Also the issue is not limited to having two richeditcontrols on the same form either but I'll come to that later.
In summary, as briefly as I can put it, when binding to the "Text" property of the richeditcontrol, If in code you set the value of the "Text" property it appears to wait until it repaints before firing the appropriate event (I assume IPropertyChanged) to let the BindingSource know the property has changed. This leads to some very unintended results.
In the attached example I have created a form with two richeditcontrols and one textedit control, the Text properties of each are bound to one of three string Properties on Class1. There are also five buttons, a "reset" one to be run between each example, and buttons 1 to 4 which are the four examples demonstrating the issue. finally there is a timer control which is a their as one more extreme workaround for the issue, but it better highlights the fault.
button 1
This is trying to programatically change the text in both the richeditcontrols at once. You'll notice when you press button 1 the first richeditcontrol is updated, but the second one is not. You may get a brief flash of the updated text but it won't stay. This is because when you set the Text property of the richeditcontrol it is not firing the binding events at that point, but waits for the code of the button to finish, and when the form is repainted it fires the event for each in order. Therefore when the first one fires it updates the underlying property, then the binding process resets all the other properties on the BindingSource to the values of the underlying data. This is by design in the binding process, as it allows for other properties changing as a result of setting the changed property. This has the result of setting the Text property of the second richeditcontrol back to the value of the underlying data not the new value. Then it fires the binding event for the second richeditcontrol which by now has corrupted data.
button 2
This demonstrates the above by setting the first Text property then starting a timer control. in the timer control event the second text property is set. this gives a few moments of time for the form to repaint and the event for the first richeditcontrol to fire, then the second one updates and it's event fires after you leave the timer event. Ok this is not the most elegant workaround, but it demonstrates the issue the best
button 3
This demonstrates that it is not just because I have two richeditcontrols. In fact, the issue can occur if you set any other data bound property on anyones(inc yours) control that is on the same bindingsource. In this case, a textedit.Text property. Button 3 has the value of the textedit's text property set after the richeditcontrol's text property. As we know from above, setting the richeditcontrol's text property doesn't fire the binding event until after it is out of code, but the textedit controls Text property behaves properly and fires instantly. This in turn refreshes the value of the Text property of the richeditcontrol back to the underlying data and our change is lost.
button4
This demonstrates that by switching these two updates around everything works ok, but it may be needed to have them the first way around.
As I said earlier I am really concerned by the HTMLText property, but I wanted to demonstrate that a potentially more used property is also affected.
Any further questions don't hesitate to ask, I have tried to explain it as clearly as I can, it took me best part of a day to get to the bottom of the issue.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi James,
Thank you for your report.
Our developers added the UseDeferredDataBindingNotifications property to the XtraRichEdit control version v2011 vol2.9/v2012 vol1.2 . So, you can use this property to resolve this problem.
Thanks,
Elliot
I have downloaded and installed V2011 vol2.9 this afternoon, and I may be being slow, it is Friday afternoon after all, but I cannot find the new property anywhere.
This issue is listed in the release notes.
Hi James,
It appears that I've posted a wrong answer here. I apologize for this.
Here is a correct answer:
Our developers added the UseDeferredDataBindingNotifications property to the XtraRichEdit control version v2011 vol2.11/v2012 vol1.2 . So, you can use this property to resolve this problem. Also, you are welcome to request a fix. For more details about this service, please read Julian's blog at http://community.devexpress.com/blogs/ctodx/archive/2008/07/10/getting-your-fix-the-devexpress-way.aspx
Thanks,
Elliot
Cheers