Visual Studio 2019 vb.net Masked Text Box is reverting the AutoSize property to "true" automatically

585 Views Asked by At

In VB.net, Visual Studio 2019, I am looking to make a Masked Text Box height taller than the AutoSize allows me to, so I use the code:

Me.MaskedTextBox.AutoSize = False

I am able to type it in and I do not get any errors and I can change the height without any issues. Even though "AutoSize" does not show in the auto complete box

If I go back to edit any part of the control though, the autosize lines disappears and the value reverts back to true, reverting the height back to the autosize allowed value.

I was looking in the MaskedTextBox in Microsoft docs and it looks like Autosize it a property that can change even though MaskedTextBox does not like Multi-line.

Is there a way to make the "autosize = false" and height to stay and not revert back?

1

There are 1 best solutions below

2
LarsTech On BEST ANSWER

Try using your own that pre-sets the property for you:

Public Class MaskedTextBoxEx
  Inherits MaskedTextBox

  Public Sub New()
    Me.AutoSize = False
  End Sub
End Class