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 tex
You can set it programatically.
textBox1.Cursor = Cursors.Arrow;
Putting the hideCaret function inside the TextChanged event will solve the problem:
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
private void textBox1_TextChanged(object sender, EventArgs e)
{
HideCaret(textBox1.Handle);
}
You could use a Label
instead. When in the designer, you set BorderStyle = Fixed3D
, BackColor = Window
and AutoSize = False
, it looks a lot like a TextBox.
However, the cursor in a TextBox is provided so that the user can scroll through the text when it is longer than the box. You'll lose that functionality with a Label, unless you are sure that it will always fit. Other than that, it is not possible to remove the cursor from a TextBox.
you can use RightToLeft Property of Text Box, set it to true, you will not get rid of the Cursor, but it will get fixed at right corner and it will not appear automatically after every text you type in your text Box. I have used this to develop an application like Windows Calculator.