如何控制masktextbox组件的焦点

如何控制masktextbox组件的焦点

本文介绍了如何控制masktextbox组件的焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了masktextbox组件,我发现了一个问题:

当我设置如下属性时:

I use the masktextbox component in my application,i find a question:
when i set property as below:

maskedTextBox1.Mask = "CX&&&&&&&&&&Y&&&&&&&&&&Z&&&&&&&&&&";
maskedTextBox1.PromptChar = ' ';

//int i = 0;



和我写点击事件如下:


and i write click event as below:

maskedTextBox1.Select(i++, 0);
maskedTextBox1.Focus();



它无法控制组件焦点。



所以我改变另一种方式如下:


it can't control the component focus.

so i change another way as below:

maskedTextBox1.SelectionStart = i++;
maskedTextBox1.Focus();



它也无法控制。



怎么能我控制了maskedtextbox焦点。

有人可以帮助我吗?


it also can't control.

how can i control the maskedtextbox focus.
can anybody help me ?

推荐答案

maskedTextBox1.Focus();
maskedTextBox1.Select(i++, 0);


this.ActiveControl = maskedTextBox1


这篇关于如何控制masktextbox组件的焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 06:28