简体   繁体   English

如何禁用文本框上的GotFocus?

[英]how to disable the GotFocus on textbox?

I have a textbox that does something on GotFocus . 我有一个在GotFocus上做某事的textbox

How can I disable the GotFocus event on this textbox ? 如何在此文本textbox禁用GotFocus事件?

How to enable it back? 如何启用它?

Sorry, I forgot - i work on Windows-mobile 6.5 对不起,我忘了 - 我在Windows-mobile 6.5上工作

Thanks in advance. 提前致谢。

May be TextBox.CanFocus = false; 可能是TextBox.CanFocus = false; and then CanFocus = true; 然后CanFocus = true; ?

You could always Enable or Disable the control as well 您也可以始终启用或禁用控件

void ButtonEnabled(bool value) {
   textBox1.Enabled = value;
}

The code above is much too short to write a routine for, but gets the point across easier. 上面的代码太短,无法编写例程,但更容易理解。

if you use WPF , TesxBox.Focusable property should be used. 如果使用WPFTesxBox.Focusable使用TesxBox.Focusable属性。 TesxBox.Focusable = true enables you to got focus. TesxBox.Focusable = true使您TesxBox.Focusable = true焦点。 TesxBox.Focusable = false - disables you to got focus TesxBox.Focusable = false - 禁用您获得焦点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM