在MaskedTextBox中放置插入符号符号、MaskedTextBox

2023-09-02 21:33:09 作者:最喜欢

我希望能够覆盖的默认行为定位插入符在屏蔽文本框。

I would like to be able to override the default behaviour for positioning the caret in a masked textbox.

默认是放置在鼠标点击的插入符,蒙面文本框已包含的字符由于面具。

The default is to place the caret where the mouse was clicked, the masked textbox already contains characters due to the mask.

我知道,你可以隐藏插入符如本post,是否有类似的定位插入符号在当控制获得焦点的文本框的开头的东西。

I know that you can hide the caret as mentioned in this post, is there something similar for positioning the caret at the beginning of the textbox when the control gets focus.

推荐答案

这应该做的伎俩:

    private void maskedTextBox1_Enter(object sender, EventArgs e)
    {
        this.BeginInvoke((MethodInvoker)delegate()
        {
            maskedTextBox1.Select(0, 0);
        });         
    }
 
精彩推荐