Remove the Caret in a textebox

  • Thread starter Thread starter Marc Robitaille
  • Start date Start date
M

Marc Robitaille

Hello group,

I need to remove the caret from the texbox. I tried with the HideCaret API
and it doesn't work. Is there a way to hide it? if yes, Is it possible to
show me how? Or if you have a link that show how to do it.

Thank you all
Marc R
[email protected]
 
Public Class clsCustomTB

Inherits TextBox

Declare Function HideCaret Lib "user32" (ByVal hwnd As Integer) As
Integer

....

Public Sub New()

MyBase.BorderStyle = BorderStyle.None

HideCaret(MyBase.Handle.ToInt32)

End Sub
 
Marc Robitaille said:
I need to remove the caret from the texbox. I tried with the
HideCaret API and it doesn't work.

'HideCaret' should work if you are using the right declares:

\\\
Public Declare Auto Function HideCaret Lib "user32.dll" ( _
ByVal hwnd As IntPtr _
) As Boolean
///
 
Marc Robitaille said:
Public Class clsCustomTB

Inherits TextBox

Declare Function HideCaret Lib "user32" (ByVal hwnd As Integer) As
Integer

...

Public Sub New()

MyBase.BorderStyle = BorderStyle.None

HideCaret(MyBase.Handle.ToInt32)

At this time the control is not yet created. Add a handler to the control's
'HandleCreated' event and try hiding the caret there.
 
It didn't work in the 'HandleCreated' event but I try in the MouseDown,
MouseMove and the MouseUp events and it work great. I put it there because
I create my textbox at runtime on a panel. I create a textbox with the use
of drag & drop. When I move my textbox on the panel, the caret show up.
So, in the mouse events, everyting is fin

Thank you for your help :-)
Marc R.
 
Thank you for your help :-)
Marc R.

Herfried K. Wagner said:
'HideCaret' should work if you are using the right declares:

\\\
Public Declare Auto Function HideCaret Lib "user32.dll" ( _
ByVal hwnd As IntPtr _
) As Boolean
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top