Search code examples
visual-studiowinformsvisual-studio-2008maskmaskedtextbox

Reset MaskedTextBox's ValidatingType in the Win Forms Designer


In a Windows Forms application, I add a MaskedTextBox to the form. Clicking the ellipsis on the Mask property opens up the Input Mask dialog. In it, I set the mask to a short date, leaving the Use ValidatingType checkbox checked.

This results in the next two lines in the designer generated code;

this.maskedTextBox1.Mask = "00/00/0000";
this.maskedTextBox1.ValidatingType = typeof(System.DateTime);

Now, when I want to revert back this change, I'd expect to be able to right click on the Mask property of the control, and select Reset. Doing that does reset the Mask property itself, but leaves the ValidatingType property untouched. Since the ValidatingType property itself isn't visible in the designer, there doesn't seem to be a way to reset this property using the Designer.

I've also tried going back into the Input Mask dialog box and setting the mask to <Custom>, which doesn't have a validating type, but it still keeps the existing ValidatingType in the designer generated code.


So, is there a way to reset the ValidatingType property using the Designer? Or do I actually have to go into the designer generated code and make the change myself?


Update

Based on Hans' answer, I found another way. After right clicking on the Mask property and choosing Reset, only the Mask property itself gets cleared. The Input Mask Dialog you get after clicking the ellipsis sets both the Mask and the ValidatingType properties.

So... using Reset isn't good enough. After using Reset, you have to go into the Input Mask dialog again and click Ok.

I still feel it is a bit buggy that the Reset doesn't reset the ValidatingType, while the dialog opened up by the ellipsis in the same property does set it.


Solution

  • Just uncheck the "Use ValidatingType" checkbox in the task dialog.