How to make a textbox non-selectable using C#

前端 未结 11 1872
轮回少年
轮回少年 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 11:45

    I had the same problem. I had a dialog up and needed multiline text to be displayed. I could not use a label as it has to be a textbox because of the multiline and text wrap.

    I first mad it readonly, but if the dialog is flashed by other windows, the text becomes selected which looks horrible. So I found the problem.

    In the form builder program (whatever it is called), there is a property for the TextBox called TabStop. I set that to false and the read-only textbox text never gets selected. Problem solved.

提交回复
热议问题