In a textbox, how can u prevent the display of the blinking cursor when you click on it?
I did read in some forums that there is call to a particular api but when i tried it in my code, an error was shown. Please provide the complete code for this purpose if possible and let me know if there is a particular event where the code should be executed.
This textbox is part of a form window that am creating for the simulation of a lan messenger. I am using C#. The form has two textboxes in order to resemble that of google talk. It would be desirable to prevent displaying the blinking cursor on the upper textbox.
I tried:
[DllImport("user32")]
private static extern bool HideCaret(IntPtr hWnd);
public void HideCaret() { HideCaret(TextBox1.Handle); }
I get the error: "DllImport could not be found."
If you want to disallow editing on the textbox, set it's ReadOnly property to true.
If you want to allow editing but still hide the caret, call the Win32 API exactly as specified:
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
...
HideCaret(myTextBox.Handle);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With