[英]How to hide textbox cursor in Windows Forms c#
I need to remove the blinking vertical line indicating the place where text would be inserted, even if I click on the TextBox. 我需要删除闪烁的垂直线,该垂直线指示将要插入文本的位置,即使单击TextBox也是如此。
Note that textbox
is already ReadOnly = true
and I don't want to disable it. 请注意,
textbox
已经是ReadOnly = true
,我不想禁用它。
Any idea? 任何想法? Thanks!
谢谢!
I finally found two working ways for solving this: 我终于找到了两种解决此问题的方法:
1. Send textbox focus away 1.发送文本框焦点
Sending focus to another component on Form initialization: 将焦点发送到表单初始化的另一个组件:
public Form1(){
InitializeComponent();
textBox1.Enter += (s, e) => { textBox1.Parent.Focus(); };
}
2. Create a Label and customize it 2.创建一个标签并对其进行自定义
In the label properties, set: 在标签属性中,设置:
BorderStyle = Fixed3D
BackColor = Window
AutoSize = False
And resize the label in the form design view 并在表单设计视图中调整标签的大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.