Hi, onto a form I’ve an UltraDateTimeEditor with the following MaskInput: {date} {time}.
When the user click over the spin button by default the control enter in edit mode with the caret positioned to the most left position. So if we have the “en-US” culture set, the control increment/decrement the month. If we have the “it-IT” (Italian) culture then the first value is the day of the month. And, of course, moving the caret we want to control others date time parts.
By default we wish to increment/decrement always the day of month regardless the system culture.
How we can accordingly move the caret when the edit mode start?
Thanks in advance.
Diego.
Thanks Mike.
I did try in sample application but it's not repeatable. I am using delegate for parent form to child. So when I hit shortcut key in the handler of delegate I give focus to my control.
Hi Saurabh,
I'm afraid I don't have a definitive answer for why that would happen. It sounds like some kind of timing issue - like something else in your application is interfering with the keyboard messages being sent to the control.
If you can duplicate this behavior in a small sample project, we could take a look, but without a sample, all I can do is make some pretty wild guesses.
If your application using multiple threading? Are you calling DoEvents in your code? Which events of the UltraDateTimeEditor are you handling? How are you setting focus to the control?
It's not only date control but even for a dropdown also. When I hit shortcut key it focus dropdown and then type it in doesn't do any thing. I need to use arrow key first after that I can type it in.
Thanks
Hi,
I have a strange issue right now. On my application I have a short cut key which gives a focus on ultradatetimeeditor. Ultradatetimeeditor is on user control and shortcut cut is on parent level. When I hit shortcut key it gives focus on date control. It selects all text on that one also and cursor is also blinking. Bur as soon as i type it in it doesn't write in it.
Once i use arrow key, only after that i can type it in.
Can you let me know what cause this issue?
Saurabh Shah
Hi Diego,
I tried this out and I am not getting the results you describe.
The first time I enter the UltraDateTimeEditor control, all of the text in the control is selected and when I use the spin buttons, this increments the year, not the month.
If I place the cursor anywhere else in the control, then the next time I come back to it, the cursor is in the same place.
But ignoring all of that, you can set the position of the cursor and the selection in the UltraDateTimeEditor in the same way you would for a TextBox - using the SelectionStart and SelectionLength properties.So for "en-US" you could do this:
private void ultraDateTimeEditor1_Enter(object sender, EventArgs e) { ultraDateTimeEditor1.SelectionStart = 3; ultraDateTimeEditor1.SelectionLength = 2; }
I'm afraid I don't see a way to make a generic solution for all cultures, though. The control does not expose any specific information about the different sections, so there's no way to determine the location of the month section.
I suppose you could get the Short Date information from the current culture and parse the string yourself to find the "mm" in it - assuming that all cultures use "mm" for the month, which I am not sure is the case.