Search code examples
vb.nettextboxmaskedtextbox

maskedtextbox alignment


I am working on a VB.Net Windows application. I am trying to use MaskedTextBox. My mask is 999999, RightToLeft is true, TextAlign is right. It is not letting me enter characters from the right. It is entering them from the left. When I type 1234 and save I get 1234____ when I expect to get ____1234.

Please tell me what I am missing.


Solution

  • This worked for me. The code is in the Form's load event.

    MaskedTextBox1.Mask = "999999"
    MaskedTextBox1.RightToLeft = RightToLeft.Yes
    MaskedTextBox1.TextAlign = HorizontalAlignment.Right