Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a masked textbox on my winforms application where if a user clicks inside of the masked textbox, the cursor will start out in that location. For example, if they click in the middle of the masked textbox there will be a blinking cursor in the middle. How can I get the cursor behavior to be such that it will default at the left-most portion of the masked textbox?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
308 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can hook into the click event and then do something like this:

    public Form1()
    {
        InitializeComponent();
        this.maskedTextBox1.Click+=new EventHandler(maskedTextBox1_Click);
    }

    private void maskedTextBox1_Click(object sender, EventArgs e)
    {
        this.maskedTextBox1.Select(0, 0);
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...