Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello All,
 
I am trying to hide the cursor in my rich text box. The following is what I have carried out:
 
<dllimport("user32")> _
    Private Shared Function HideCaret(ByVal hwnd As IntPtr) As Integer
 
    End Function
 
 Private Sub rtbReport_GotFocus(sender As Object, e As System.EventArgs) Handles rtbReport.GotFocus
        HideCaret(rtbReport.Handle)
    End Sub
But I am afraid the above does not work.
 
Any ideas would greatly be appreciated it.
 
[edit] code tags added [/edit]
Posted 25-May-12 2:50am
Edited 25-May-12 9:59am
Nelek51.4K
v2
Comments
SAKryukov at 25-May-12 11:54am
   
Why hiding a caret? Even if the document is read-only, it can be used to select some text and copy it to the clipboard. Removing it would hurt the user's right for information.
--SA
behzad1978 at 26-May-12 12:50pm
   
Hello Sakryukov,
Many thanks for your reply. The main objective here is to state what the application is doing and has already implemented. The customer dislike the blinking cursor and as a result one must do their best to deliver. I implemented this action many years back in VB6 so I assumed the implementation would be just as easy in VB.NET.
Gregory.Gadow at 25-May-12 16:50pm
   
Are you trying to hide the cursor (the mouse pointer) or the caret (the blinking bar that indicates the current position within the text)? And why?
 
You cannot hide the cursor, although you can use the control's Cursor property to change the cursor that appears when the user hovers over the control. There really is no effective way to hide the caret, but you can use the control's ReadOnly property to make it... well, read only. That means the user cannot edit what is there.
SAKryukov at 28-May-12 19:44pm
   
Agree. I suggested the alternative which works very well, but it might depend on the application requirements. I think it might be interesting, please see.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'm sorry if my advice does not address the problem, but you could think of a very good alternative to using RichTextBox. There are a couple of very good components on CodeProject offering rendering of HTML instead. Please see:
 
For Forms:
A Professional HTML Renderer You Will Use[^].
 
For WPF:
WPF HTML Supported TextBlock[^].
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I am afraid by implementing the following does not hide the rich text box control caret:
 
<dllimport("user32")> _
Private Shared Function HideCaret(ByVal hwnd As IntPtr) As Integer
 
End Function
 
‘Your rich text box=rtbReport
Private Sub rtbReport_GotFocus(sender As Object, e As System.EventArgs) Handles rtbReport.GotFocus
HideCaret(rtbReport.Handle)
End Sub
 
Solution:
The method which eventually worked for me is to call
rtbReport.TabStop = False Within the form load event.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 540
1 OriginalGriff 290
2 CPallini 240
3 BillWoodruff 155
4 ChauhanAjay 149
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100