How do I hide the input caret in a System.Windows.Forms.TextBox?

前端 未结 5 1819
暖寄归人
暖寄归人 2021-01-12 07:21

I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input c

5条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 07:52

    If you disable the text box (set Enable=false), the text in it is still scrollable and selectable. If you don't like the visual presentation of a disabled text box (gray background usually) you can manually override the colors.

    Be warned, manually overriding colors is going to make your form/control look weird on systems that do not use the default color/theme settings. Don't assume that because your control is white that everyone's control is going to be white. That's why you should always use the system colors whenever possible (defined in the System.Drawing.SystemColors enumeration) such as SystemColors.ControlLight.

提交回复
热议问题