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.
Unfortunately, activation email could not send to your email. Please try again.

MaskedTextBox ignores handled=true

Thread ID:

Created:

Updated:

Platform:

Replies:

73067 Apr 18,2008 05:01 AM Apr 25,2008 07:02 AM Windows Forms 1
loading
Tags: EditControl
Sascha Wald
Asked On April 18, 2008 05:01 AM

Syncfusion ver. 5.2

task:
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 07:02 AM

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)
currentText.Append(Me.maskedEditBox1.Text)
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:

http://websamples.syncfusion.com/samples/Tools.Windows/F73067/main.htm

Please let me know if any concerns.

Regards,
Fathima


CONFIRMATION

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.

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.

;