简体   繁体   中英

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.

闪烁的垂直线

Note that textbox is already ReadOnly = true and I don't want to disable it.

Any idea? Thanks!

I finally found two working ways for solving this:

1. Send textbox focus away

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

In the label properties, set:

  • BorderStyle = Fixed3D
  • BackColor = Window
  • AutoSize = False

And resize the label in the form design view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM