Hi,
When user enters the only data and tabs out without entering the values for HH:MM:SS, on focus lost, the values are being cleared from the control.
Please do let me know if i am missing in the control settings.
Hi Vikram,
You can try hooking into the Validating event and check to see if hour, minute and second sections are blank and if so auto-fill them.
Sandip
Hi Sandip,
Thanks for your reply.
Actually, we did try to handle it in the same as you have specified in the in your reply. But, the value of the control at the Validating Event is found to be null. That means, the values are getting cleared even before the validating event fired?
This is the input which we have used in our application: DateTimeContol.MaskInput = "yyyy/mm/dd hh:mm:ss"
Please do let us know if you have any solutions for this issue.
Thanks and Regards,
Vikram
Did you guys find a solution for this issue. I'm facing the same problem!
i have almost same problem. But i want to have default value, for example
date hh/mm/ss and someone set date 11/34/__ leave seconds empty, i would like to have default value fot that be 00. Now, if conotrl lost the focus, both, data and time are emty.
Does someone have some idea?
I don't think that there's a public method exposed for determining what the currently edited section is, but you can hack this by looping through all of the sections of the editor and comparing it to the SelectionStart property; you can also get the MinuteSection by doing the same thing. For a quick example, see the following code:
private void ultraDateTimeEditor1_BeforeExitEditMode(object sender, BeforeExitEditModeEventArgs e){ EditorWithMask editor = (EditorWithMask)this.ultraDateTimeEditor1.Editor; int charactersEncountered = 0; SectionBase currentEditSection = null; SectionBase section = null; for (int i = 0; i < editor.Sections.Count; i++) { section = editor.Sections[i]; charactersEncountered += section.DisplayChars.Count; if (this.ultraDateTimeEditor1.SelectionStart <= charactersEncountered) { currentEditSection = section; break; } } MinuteSection minuteSection = currentEditSection as MinuteSection; if (minuteSection != null) { // Do work here }}
There are also other section types you can check for, like DaySection, YearSection, HourSection, etc.
As for there being an event when someone puts '9' in the month section, you could handle the TextChanged event and get the current section through the code above. There's no guarantee, however, on many sections that pressing '9' will not allow the user to press any other keys. In the case of a month section, this will work, but in a day section, the user could type '9', then press the left arrow key and then '1' so that they have '19' as the day.
-Matt
Matt this is really useful, thanks!
I have one more question, in this case I should split string, and this is depended on mask input format, so does have some other way to say Give me value of minutes?
--
Or how I can to know on what kind of group fields is cursor? Is it minute or hour or months...?
Does exist some event what is firing when someone put number 9 for months (for example)? In that case this is final number, can not be 9* (* - any other number)
Thanks!
I don't think that you can have a default value on a per-section basis, since I believe this is determined internally for each section based on its type. What you could do is handle the BeforeExitEditMode event and fill in the blanks yourself. The following code only checks to see if the seconds section is blank, and if so replaces it with '42' (and my test assumes a MaskInput of "yyyy/mm/dd hh/mm/ss"):
private void ultraDateTimeEditor1_BeforeExitEditMode(object sender, Infragistics.Win.BeforeExitEditModeEventArgs e){ string currentText = this.ultraDateTimeEditor1.Editor.CurrentEditText; string[ dayTimeSplit = currentText.Split(' '); string[ timeSplit = dayTimeSplit[1].Split('/'); if (timeSplit[2] == "__") { timeSplit[2] = "42"; string newDateString = String.Format("{0} {1}:{2}:{3}", dayTimeSplit[0], timeSplit[0], timeSplit[1], timeSplit[2]); DateTime newDate = DateTime.Parse(newDateString); this.ultraDateTimeEditor1.Value = newDate; }}