We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MaskedTextBox ignores handled=true

Thread ID:





73067 Apr 18,2008 09:01 AM UTC Apr 25,2008 11:02 AM UTC WinForms 1
Tags: EditControl
Sascha Wald
Asked On April 18, 2008 09:01 AM UTC

Syncfusion ver. 5.2

we need a control to enter spent-time data in format hhh:mm e.g. 239:59 means 239 hours and 59 minutes.
i want to use your MaskedEditBox-Control for that, the mask is ###:## (or ##9:99).
to enter the minutes, i'd like to suppress entering the 10m-part bigger than 5 (e.g. there is not such a 68 minutes task, that task has a duration of 1h and 8 minutes)

i tried to use the keypress-event, but cannot suppress or handle the event when the user enters a number > 5:
If TimeSpentTextBox.SelectionStart = 5 Then
If Not CType(Microsoft.VisualBasic.Val(e.KeyChar), Integer) < 6 Then
e.Handled = True
End If
End If
the e.Handled is simply ignored.

what can I do? thank you

Fathima Shalini P [Syncfusion]
Replied On April 25, 2008 11:02 AM UTC

Hi Sascha,

Thank you for your interest in Syncfusion Products.

Preventing the user to enter invalid time, can be done using MaskCustomValidate event of MaskedEditBox. The following code snippet illustrates this:

Private Sub maskedEditBox1_MaskCustomValidate(ByVal sender As Object, ByVal e As

Syncfusion.Windows.Forms.Tools.MaskCustomValidateArgs) Handles maskedEditBox1.MaskCustomValidate
currentText.Remove(0, Me.currentText.Length)
If e.CurrentIndex =4 Then
currentText(e.CurrentIndex) = e.CurrentCharacter
If e.CurrentCharacter > "5"c Then
e.Handled = True
e.Accepted = False
End If
End If
End Sub

Please find the simple sample in the following link:


Please let me know if any concerns.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon