在MaskedTextBox中放置插入符号 [英] Position the caret in a MaskedTextbox

查看:153
本文介绍了在MaskedTextBox中放置插入符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我知道,你可以隐藏插入符如本<一个href="http://stackoverflow.com/questions/44131/how-do-i-hide-the-input-caret-in-a-systemwindowsformstextbox">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);
        });         
    }

这篇关于在MaskedTextBox中放置插入符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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