I've seen numerous posts about cursor position in the UltraMaskedEdit but I don't seem to find what I need.
I have an UltraMaskedEdit with a mask of (###) ###-#### aaaaaaaaaa (phone number with extension). Because of UI space constraints the editor is not wide enough to display all the text if the user has entered data in the extension part of the mask. When tabbing into the field all entered data is selected and if an extension is entered this shifts the visible data all the way to the right so the full extension is visible but most of the phone number is not. When tabbing out it's left that way. What I need to do is when leaving this editor or when it loses focus to set this back so the user can see the phone number.
I've tried setting SelectionStart but everywhere I look if the user is just tabbing through it's already at 0 so setting it to 0 (and 1) doesn't do any good. I've tried setting the SelectionStart to .Text.Length-1 and then to 0 (and 1) and that doesn't make any difference except to insure that the text is shifted in the wrong direction if it wasn't before. I've tried this in LostFocus, PreviewKeyDown, KeyUp and nothing seems to work.
Any suggestions?
Hello,
I believe that I managed to achieve this behavior and put it all in my sample project and attached it to this post. Please review it and feel free to let me know if I misunderstood you or if you have any other questions.
Your example almost works
For example, take the phone number (555) 555-1212 x123
I attached an updated version of your project to show you what happens when there is already data in the masked editor and the user tabs into and out of the control.
Hello again,
Could you please try adding the following line before setting the 'SelectionStart' to '0' in the 'LostFocus' event:
ultraMaskedEdit1.SelectionLength = 0;
Please do not hesitate to ask if something comes up.
Thank you Boris, that did the trick.