When tabbing into an ultraNumericEditor or for that matter any Infragistics control we want all the text to be selected. When we click in a control we want the cursor to be placed where we click. We do not want the control to retain last SelectionStart and SelectionLength values. Basically we are trying to get the Infragistics controls to work like they do In Office 365 Outlook Options.
I have read these posts and a few others.
Different behavior of text selection when tabbing into an ultratexteditor
Numeric Editor Question
I can accomplish this in the ultraTextEditor by using the Enter event but does not work if I use the AfterEnterEditMode. I thought this would also solve my issues with ultraNumericEditor, ultraCurrencyEditor and ultraDateTimeEditor because they seem to be built using some variation of textbox/ultraTextEditor. However the event does not work the same. It always selects all the text.
I found a way to get the desired behaviour in ultraNumericEditor, ultraCurrencyEditor and ultraDateTimeEditor by setting SelectionStart and SelectionLength to basically select all characters during the Validating event. I could do this in the Leave event if that is better. It would have been much easier if I could simply keep the control from retaining this information but I could not find a way.
I have attached a test solution with the controls working as I would like them to. Could be luck that they are working correctly.
The questions I have:
0081.SelectAll.zip
Hello Michael,
It appears that the UltraMaskedEdit control’s architecture is quite a bit different than the other “masked editors.” It actually has a completely different base-class and as such, a different API.
Please let me know if you have any other questions or concerns on this matter.
I was going to mention that UltraMaskedEdit works just like UltraTextEditor. I only needed to call SelectAll() in the control Enter event to accomplish my goal. I found that strange considering the other controls were built as "masked" editors. I also found it strange that UltraMaskedEdit does not have BeforeExitEditMode or AfterEnterEditMode.
Thank you for your update on this matter. I am glad that BeforeExitEditMode is working better for you in this case and is allowing you to achieve your goal with less overhead.
I actually do not trap on tab or any other keystrokes. I let the control take care of that I only trick the control when exiting by setting SelectionStart and SelectionLength. Using the BeforeExitEditMode actually works really well. It also allows me to use only one event instead of two. I can also remove the fields that are no longer needed. From what I can tell I am accomplishing the same goal just with less overhead. I have attached the updated solution.0456.SelectAll2.zip
Thank you for your update on this matter.
From your response, it sounds like it is working in the way that you would expect. As mentioned in my above response, clicking into the editors will clear the selection and place the caret where you clicked, and tabbing in will revert to the “saved selection” which you are setting in your Validating event in this case. I think this is a valid way of ensuring that you select all when tabbing back into the editors while also ensuring that the caret is placed where you click.
An alternative event that you could potentially set this in would be the Before/AfterExitEditMode events as well. Unfortunately, the Before/AfterEnterEditMode events do not have any information on whether or not it is coming from a click or tab navigation, so I can’t really recommend doing this there.