How to Disable Cursor in Textbox

How to hide textbox cursor in Windows Forms c#

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

Disable iBeam pointer in TextBox using VB.NET

Use the HideCaret() API call from the GotFocus() event of your TextBox:

Private Declare Function HideCaret Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean

Private Sub TextBox1_GotFocus(sender As Object, e As EventArgs) Handles TextBox1.GotFocus
HideCaret(TextBox1.Handle)
End Sub

disable field but allow to put the cursor on it and allow to copy from it

use cursor:pointer; in inline style and readonly="true"
check this

<input  style = "width:100px;cursor:pointer;"  readonly ="true" value="hellohellohell"/> 


Related Topics



Leave a reply



Submit