MaskedTextBox.Modified not worknig

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Visual Studio 2005 to develop a Windows Application using Visual
Basic. I have added a MaskedTextBox to one of my forms and am trying to check
it for changes.

There is a property called MaskedTextBox.Modified that is suppose to return
'True' if the controls contents have been modified. Property doesn't seem to
be working because no matter how much data I type (not programmically set)
into the maskedtextbox it always returns 'False'.

I found a single reference to this problem using a google search and the guy
basically said the 'Modified' property only works if you do not set the
'Mask' property of the MaskedTextBox, which seems like a bug since you
wouldn't use a maskedtextbox if you didn't want to use a mask.

I would love some insight or feedback if possible and I've included the link
to the msdn description of this property below:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.textboxbase.modified.aspx
 
As a work around I am setting this property manually using the
maskedtextbox.textchanged event. The following is an example:

Private Sub SetMaskedTextBox_Modified(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mskMyField.TextChanged
mskMyField.Modified = True
End Sub

It may be necessary to set the property to false in your MyBase.Load event
handler procedure if you are setting a default value for the MaskedTextBox. I
set a default value for phone number and then set the mskMyField.Modified
property to false as follows:

Private Sub OnFormLoad(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
mskMyField.Text = "916"
mskMyField.Modified = False
End Sub
 
Back
Top