如何使用C#使文本框不可选择 [英] How to make a textbox non-selectable using C#

查看:123
本文介绍了如何使用C#使文本框不可选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将C#/.NET用于Windows窗体应用程序.我有一个文本框.如何使文本框不可选择?

I'm using C#/.NET for a Windows Forms application. I have a text box. How can I make the text box unselectable?

我不想禁用整个文本框.

I don't want to disable the complete textbox.

推荐答案

在文本框的'Enter'事件中,将ActiveControl设置为其他内容:

In the 'Enter' event of the textbox set the ActiveControl to something else:

    private void txtMyTextbox_Enter(object sender, EventArgs e)
    {
        ActiveControl = objMyOtherControl;
    }

这篇关于如何使用C#使文本框不可选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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