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 ,
If you are using UltraNumerickEditor for example, you could set NumerickType to "Double", then to set MaskInput to “{double:-9.4:c}” in order to allows user to enters decimal values with 4 digits after decimal separator. MaskImput will be applied by default, when editor is in edit mode. Then you could set FormatString property to “#.00” in order to display editor's value with 2 digits after the decimal separator. FormatString will be used of editor in order to displays actual value of the editor in specific format, when it is not in edit mode. So you will be able to have a decimal value with 4 digits after decimal separator, when editor is in edit mode and you will display decimal value with 2 digits after decimal separator when editor is not in edit mode.
Please let me know if you have any further questions.
Hello,
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?
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.
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,
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