all groups > dotnet windows forms > august 2006 >
You're in the

dotnet windows forms

group:

MaskedTextBox.Modified not worknig


MaskedTextBox.Modified not worknig Locker
8/29/2006 4:17:01 PM
dotnet windows forms:
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:

RE: MaskedTextBox.Modified not worknig Locker
8/30/2006 8:25:01 AM
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


[quoted text, click to view]
AddThis Social Bookmark Button