蒙面文本框输入左对齐 [英] Masked TextBox Input Align Left

查看:144
本文介绍了蒙面文本框输入左对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的WinForms应用程序一个蒙面的文本框,其中,如果用户点击文本框蒙面里面,光标会在该位置开出。例如,如果它们在掩蔽文本框的中间点击会有在中间闪烁的光标。我怎样才能得到光标行为是这样的,它会默认在蒙面文本框的最左边的部分?

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?

推荐答案

你可以连接到点击事件,然后做这样的事情:

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);
    }

这篇关于蒙面文本框输入左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆