MaskedTextBox.TextChanged Event

Editors for WPF Forum

Posted 14 years ago by Marcel Konnegen
Version: 10.1.0523
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar
Hello Support,

we have encountered the following problem during our development. Inside a TextChanged-event handler, we triger an operation that itself changes the Text of the MaskedTextBox. However, this change does not get reflected in the WPF UI. We can confirm, that the value gets set correctly, by inspecting new- and oldValue of the EventArgs. The following little example shall show you the problem.

1) Setting the value to 1.
1a) The TextChanged event triggers the setting of the value to 99999
1b) The GUI still shows 1, even though, the TextChanged event did show 1 as old- and 99999 as newValue.

Even stranger...when we now change the text from 1 to e.g. 12, then the EventArgs of the TextChanged event will show 99999 as old- and 12 as newValue.

We hope you can help us quickly.

Thanks in advance
Marcel

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marcel,

The MaskedTextBox does not currently support setting the Text property while in a TextChanged handler. Instead, you should use the TextChanging event and update the text there.


Actipro Software Support

Posted 14 years ago by Marcel Konnegen
Avatar
Hello Support,
thank you for the quick reply. Can you give us an estimate on when this false behavior will be corrected or maybe even provide us with some kind of a hotfixed version, where this behavior is supported? It is not an option for us, to use the TextChanging event, because inside the event we initiate a roundtrip, which involves other servers. These communicate with our part of the system via Interfaces and do not return the corrected value inside the TextChanged event, which would enable us, using the TextChanging-event to update the corrected value in the EventArgs. This is a showstopper for us.
I find it odd, that the regular WPF TextBox does support the expected behavior.

Would it be possible to use our approach inside the TextChanging event...meaning setting the value NOT by using the EventArgs but by setting it from outside?

Thank you for your help
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marcel,

We were able to make a few small tweaks to allow Text to be set inside a TextChanged handler. This will be included in the next maintenance release.


Actipro Software Support

Posted 14 years ago by Marcel Konnegen
Avatar
Hello Support,
thank you very much for your help.

[Modified at 10/07/2010 01:40 AM]
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.