Well, it manifests itself as erratic, not the first time around, but when the control gets the focus after e.cancel = true in a validating routine, or when focus is set programatically or when you select the control with the mouse. When you enter numeric characters it does not render what you enter. When I either "kill" the binding or comment our this routine, this erratic behaviour does not manifest itself.
I've googled . I've seen other people having similar albeit not identical problems. One MS guy suggested to add a textbox and bind that and leave the maskedtextbox unbound. Thought that to be somewhat overkill.
I used maskedtextbox because like the textbox in vfp it has a mask, and I'm kind of used the concept.
Thanks for caring.
Marc
PS: you're telling me that in C# you don't have that problem right? Could it be a VB problem, but it's been around for years, is it possible that they did not correct that "feature"? I know, I know, it is possible ....
>Sorry, didn't realize you were doing this within the TextBox class until I looked at the link - in which case I think the code should work.
>Just checked - works for me. What unexpected behaviour are you seeing (and are you sure it's related to the override) ?
>
>>Thanks Viv, I will definitely give that a try. I was wondering what the difference was and why those guru's suggested that construction, (but did not dare asking :) )
>>
>>
>>>Put the code directly in the KeyPress event handler rather than overriding the OnKeyPress method
>>>(Just double click on the event in the properties window to create the stub)
>>>
>>>>Why, o why does this cause eratic behaviour in my (bound) maskedtextbox(es)?
>>>>
>>>>Is there a fatwa against maskedtexboxes that I should know of?
>>>>
>>>>
>>>> Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs)
>>>> ' http://www.syncfusion.com/FAQ/windowsforms/faq_c94c.aspx#q1121q
>>>> If e.KeyChar = Chr(13) Then 'CChar(13)
>>>> e.Handled = True
>>>> Else
>>>> MyBase.OnKeyPress(e)
>>>> End If
>>>> End Sub
>>>>
>>>>
>>>>Thanks.
>>>>
>>>>Marc
>>>>
>>>>PS : I need this so to disable the beep each time the user completes a field with the enter key.
If things have the tendency to go your way, do not worry. It won't last. Jules Renard.