I am using a derived UltraTextEditor to allow users to edit numbers in various free form formats. When rendering the value, the decimal places are truncated. When editing, all decimal places need to be shown. Then when user edits and leaves Edit mode, the string is converted back to a value.
For example, value = 1.2345678 shows as 1.23. When the user starts to edit, the value needs to be shown as 1.2345678 such that the user edits the actual value. Else with no edits, there is a round trip error when the string converts to the value as 1.23.
How do I refresh the editor's text when entering edit mode. I have overridden the OnBeforeEnterEdit event and have tried changing the UltraTextEditor.Text, the Editor.Text and Editor.Textbox.Text. None seem to trigger the editor to redisplay. I am using a DataFilter to format the text in the Editor -> Display conversion. The DataFilter is not called to do the any conversion when EnterEditMode.
Any suggestions? Thanks,
Wendy
Hello Wendy,
maybe one possible approach could be if you handle ultraTextEditor1_MouseEnterElement() event. This event will fired before DataFilter. Other possible approach could be to inherite our UltraTextEditor and extend it with your own custom event which fired before DataFilter.
Let me know if you have any questions.
Regards
Hello,
Thanks for the sample. This does most of what I was attempting. I've trapped the events to realize that the DataFilter calls happens before BeforeEnterEditMode and when called the editor is not InEditMode. In my code, the control actually renders several properties of an object but edits only the double and I was using the BeforeEnterEditMode to change the value of the control based on various properties and then format with the DataFilter.
Instead of using BeforeEnterEditMode, is there any other method that occurs before the DataFilter calls for conversion? Else, I can rework my code based on using the Focused state to do the mapping for Owner -> Editor and Editor -> Display. Wil this work for both stand alone and embedded editors?
Thanks
Hello Wendy Smith,
We are still following this forum thread.Have you been able to take a look at the attached sample?
Please feel free to let us know if you have any other questions with this matter.
Hello ,
Yes, you could implement your own logic for formatting, using IEditorDataFilter interface and to apply it to UltraTextEditor. I have implemented one possible variant to do this in the attached sample. Please run the sample. When UltraTextEditor is in edit mode (actually is focused), it will display “12.2345”, if it is not in edit mode and contains numeric value it will format it as “#.00” (will displays 12.23). I hope that this will helps you.
Please let me know if you have any further questions.
What you describe is the behaviour I am looking to achieve but I am using the UltraTextEditor and overriding the Value property to allow custom formating. Is it possible to have different format strings when using a DataFilter to apply the format?