Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable cursor in textbox?

Tags:

c#

textbox

Is there any way to disable cursor in textbox without setting property Enable to false? I was trying to use ReadOnly property but despite the fact that I can't write in textbox, the cursor appears if I click the textbox. So is there any way to get rid of this cursor permamently?

like image 576
Matjas Avatar asked Sep 16 '10 21:09

Matjas


People also ask

How do I get rid of the text cursor?

situated at the top right. Select Settings from the drop-down menu that appear. Scroll to the end of the page, and click to expand Advanced settings. Scroll to the Accessibility section and disable the toggle next to 'Navigate pages with a text cursor' to turn off the blinking cursor.

How do I find my cursor position?

Once you're in Mouse settings, select Additional mouse options from the links on the right side of the page. In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK. To see it in action, press CTRL.


1 Answers

In C#, you can use the following read-only textbox:

public class ReadOnlyTextBox : TextBox {     [DllImport("user32.dll")]     static extern bool HideCaret(IntPtr hWnd);      public ReadOnlyTextBox()     {         this.ReadOnly = true;         this.BackColor = Color.White;         this.GotFocus += TextBoxGotFocus;         this.Cursor = Cursors.Arrow; // mouse cursor like in other controls     }      private void TextBoxGotFocus(object sender, EventArgs args)     {         HideCaret(this.Handle);     } } 
like image 195
Mikhail Semenov Avatar answered Sep 19 '22 13:09

Mikhail Semenov