Is there a way to force the cursor to the right or left edge of a MaskedTextBox?.If the tab key is used there is no problem. Only when the mouse clicks in the box. I want the insertion point to always be on the right for numeric data and on the left for text.

  • You could do something like the following in the MouseUp event for the maskedtextbox control:

          method-id maskedTextBox1_MouseUp final private.

          procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.

            invoke type SendKeys::Send("{HOME}")

          end method.

    If your control's RightToLeft property is set to Yes then this will position the cursor to the right most position.

    If RightToLeft is set to No then it will position the cursor on the leftmost position.

    You could also use the MouseClick event and use the following:

             set maskedTextBox1::SelectionStart to 0


  • Verified Answer

    Thanks Chris, That was just what I needed!