Iñigo
Iñigo

Reputation: 2016

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.

Blinking vertical line

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

Any idea? Thanks!

Upvotes: 2

Views: 5263

Answers (1)

Iñigo
Iñigo

Reputation: 2016

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

Upvotes: 3

Related Questions