I want to hide the caret in the RichTextBox control and do that with the win api function HideCaret(),but it doesn't work.The cursor is still visible and blinking.Where i should call the function.I tried in the Enter event of the control but doesn't work again.As far as i know i should call the HideCaret() when the RichTextBox gets the focus.Is that right?
Here is the code:

[DllImport("User32.dll")]
static extern Boolean HideCaret(System.IntPtr hWnd);

private void richTextBox1_Enter(object sender, EventArgs e)
{
HideCaret(richTextBox1.Handle);
}

You call this once the control became active, then nothing called after that, I think you should use Observer pattern to keep monitoring your richtextbox, as it selected call this method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.