Remove Caret from textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I am trying to remove the caret (i.e. the blinking bar) from a textbox.
Anyone knows the trick to do this please?

Thanks and Regards
J
 
J,

You should be able to call the HideCaret API function through the
P/Invoke layer, passing the handle to the textbox.

Hope this helps.
 
Thanks, the code is as follows:

You need to make this declaration in order to use the P/Invoke Layer

// P/Invoke to hide caret
[DllImport ( "User32.dll" )]
static extern Boolean HideCaret ( System.IntPtr hWnd );

All that remains then is to call the function like so from your method:

HideCaret ( tbConsole.Handle );

Do not forget the following using clause, otherwise you get a compile-time
error:

using System.Runtime.InteropServices;

By the way, thanks very much for the answer.

Regards
Joseph.

Nicholas Paldino said:
J,

You should be able to call the HideCaret API function through the
P/Invoke layer, passing the handle to the textbox.

Hope this helps.
 
Back
Top