---
title: "C# How to Disable Cursor in Textbox?"  
description: "C# How to Disable Cursor in Textbox?"  
author: "Royce Roy"  
published: 2013-11-14  
updated: 2013-11-14  
canonical: https://www.mindstick.com/forum/1728/c-sharp-how-to-disable-cursor-in-textbox  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# C# How to Disable Cursor in Textbox?

Hi Guys\
I have a read only [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) in my winform [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) and I want to [disable](https://www.mindstick.com/forum/12901/how-to-disable-enable-input-box-in-aspx-with-value-from-sql) the cursor. How to do it?\
Thanks

## Replies

### Reply by Pravesh Singh

Hi Royce,

```
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);    }}
```


---

Original Source: https://www.mindstick.com/forum/1728/c-sharp-how-to-disable-cursor-in-textbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
