How to make a textbox non-selectable using C#

前端 未结 11 1951
轮回少年
轮回少年 2021-02-19 11:09

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.

11条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 12:06

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

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

提交回复
热议问题