01-23-2014 11:42 PM
I use numeric edit controls quite a bit, and I've come across the situation where the user has set a new value in the control but has not "committed" it in the sense that the enter key is not used nor have up/down arrows been used nor has the control lost focus. When another control is then cleft clicked with the mouse (e.g. a "start" button") the numeric edit control continues to display the altered value, BUT
There's no value changed, leave, or validated event generated !? I'm missing something very basic here ... seems to me that these events should all be generated when the focus changes to the start button? If I could respond to a Leave or lost focus event then I could at least maybe try to force a commit onto the numeric edit, even if the normal event model doesn't do that on leave or lost focus.
Does anyone know where I can find a good description of the windows control event model? Seems to be a very dense topic.
I can use a text changed event to capture the new value, at the expense of the callback getting invoked lots of times as the text changes as the new value is entered into the control - but that seems excessive. I set the validation to be triggered by the change event but that just results in the validation apparently discarding the intermediate change to the text.
I suppose the answer might be "don't do that" - the operator just has to know that it's not enough to simply change the text in the control - either use the enter key, or use the up/down arrows to ensure that the new value has been accepted.
01-24-2014 12:28 AM
I think I have some insight into this - the START button is on a toolstrip so for a reason only microsoft knows, the focus never leaves the numeric edit control, there's no lost focus, leave, or validated event, the cursor's still blinking in the numeric edit which shows the changed but uncommitted value. So the application then executes using the original value of the control despite it showing a changed value.
I still don't see why it didn't behave differently when I set the "validate on change" property for the numeric edit - but when this was set, whenever I changed the text on the numeric value, the control immediately discarded the changed text and returned to its previous value. Guess I don't understand what validation means.