473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

RichTextBox Label URL?

JZ
Hi,

I remember reading sometime ago that is possible to create a RichtextBox
label.

Has anyone got any source or a URL.

I'm looking for improvements on just setting ReadOnly = true or Enabled =
false.
Something which hides the caret / selection character.

Help!!!!!!!!!!!!!!!!!!!

--
JZ
Nov 21 '05 #1
8 2774
If you simply want to hide the caret, here's a link:
http://tinyurl.com/3kkdc

hope this helps..
Imran.

"JZ" <jj@anon.anon.com> wrote in message
news:41***********************@news.dial.pipex.com ...
Hi,

I remember reading sometime ago that is possible to create a RichtextBox
label.

Has anyone got any source or a URL.

I'm looking for improvements on just setting ReadOnly = true or Enabled =
false.
Something which hides the caret / selection character.

Help!!!!!!!!!!!!!!!!!!!

--
JZ

Nov 21 '05 #2
JZ
Yeah I'd seen that, I've tried various events but it still shows selection.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.Enter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseDown
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.MouseEnter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles RichTextBox1.SelectionChanged
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseUp
HideCaret(Me.RichTextBox1.Handle)
End Sub

Any further advice?

--
JZ
Nov 21 '05 #3
try these:
http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q949q

http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q866q

hope that helps..
Imran.

"JZ" <jj@anon.anon.com> wrote in message
news:41***********************@news.dial.pipex.com ...
Yeah I'd seen that, I've tried various events but it still shows selection.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.Enter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseDown
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.MouseEnter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.SelectionChanged
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseUp
HideCaret(Me.RichTextBox1.Handle)
End Sub

Any further advice?

--
JZ

Nov 21 '05 #4
JZ
Hi,

Well I think a combination of
'--------
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
' WM_NCLBUTTONDOWN WM_LBUTTONDOWN
If Me.ReadOnly AndAlso (m.Msg = &HA1 OrElse m.Msg = &H201) Then
Console.WriteLine("ignored")
Return 'ignore it
End If
MyBase.WndProc(m)
End Sub 'WndProc
'--------
And
'--------
HideCaret(Me.RichTextBox1.Handle)
'--------

Should do it, but I haven't quite figured it out yet.
Its late in the UK, I'll work on it tomorrow.

Thanks,

--
JZ
"Imran Koradia" <no****@microsoft.com> wrote in message
news:Ob***************@TK2MSFTNGP12.phx.gbl...
try these:
http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q949q

http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q866q

hope that helps..
Imran.

"JZ" <jj@anon.anon.com> wrote in message
news:41***********************@news.dial.pipex.com ...
Yeah I'd seen that, I've tried various events but it still shows

selection.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.Enter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseDown
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.MouseEnter
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object,

ByVal
e As System.EventArgs) Handles RichTextBox1.SelectionChanged
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = 0
HideCaret(Me.RichTextBox1.Handle)
End Sub
Private Sub RichTextBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseUp
HideCaret(Me.RichTextBox1.Handle)
End Sub

Any further advice?

--
JZ


Nov 21 '05 #5
Hi JZ,
use this http://www.codeproject.com/vb/net/rtflabelcp.asp

Greeting

Thomas

"JZ" <jj@anon.anon.com> schrieb im Newsbeitrag
news:41***********************@news.dial.pipex.com ...
Hi,

I remember reading sometime ago that is possible to create a RichtextBox
label.

Has anyone got any source or a URL.

I'm looking for improvements on just setting ReadOnly = true or Enabled =
false.
Something which hides the caret / selection character.

Help!!!!!!!!!!!!!!!!!!!

--
JZ

Nov 21 '05 #6
JZ
That still shows the selected text, not really a label!

--
JZ
Nov 21 '05 #7
JZ
Hi,

I have come up with a solution, its not 100% but I think its as good as I'm
going to get it.
If you click and move your mouse over the label from start to finish you get
a little flicker.
But apart from that it works, you can still use URLs too.

Well just in case anyone is reading this in the future here's to code....

Imports System.Windows.Forms
Imports System.ComponentModel

Public Class ReadOnlyRichTextBox
Inherits RichTextBox

Private Declare Auto Function HideCaret Lib "user32.dll" (ByVal hwnd As
IntPtr) As Int32

Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
HideCaret(Me.Handle)
End Sub

Protected Overrides Sub OnEnter(ByVal e As EventArgs)
HideCaret(Me.Handle)
End Sub

<DefaultValue(True)> Public Shadows Property [ReadOnly]() As Boolean
Get
Return True
End Get
Set(ByVal Value As Boolean)
End Set
End Property

<DefaultValue(False)> Public Shadows Property TabStop() As Boolean
Get
Return False
End Get
Set(ByVal Value As Boolean)
End Set
End Property

Public Sub New()
MyBase.ReadOnly = True
MyBase.TabStop = False
Me.SetStyle(ControlStyles.Selectable, False)
HideCaret(Me.Handle)
End Sub

Private Sub ReadOnlyRichTextBox_SelectionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles MyBase.SelectionChanged
Me.SelectionLength = 0
HideCaret(Me.Handle)
End Sub

Private Sub ReadOnlyRichTextBox_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
HideCaret(Me.Handle)
End Sub

Private Sub ReadOnlyRichTextBox_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
HideCaret(Me.Handle)
End Sub

End Class

If anyone improves on that please post in here, even months ahead.

--
JZ
Nov 21 '05 #8
JZ
In fact if you don't need to use URLs then you can add.

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
' WM_NCLBUTTONDOWN WM_LBUTTONDOWN
If Me.ReadOnly AndAlso (m.Msg = &HA1 OrElse m.Msg = &H201) Then
Console.WriteLine("ignored")
Return 'ignore it
End If

MyBase.WndProc(m)
End Sub 'WndProc

I also forgot to mention that you'd need to change the borderstyle to none
and the background color.

--
JZ
Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
1
by: Yuelin | last post by:
Hi all I are stuck on a problem with RichTextBox control. On a simple form - a label, a richtext control, a button, in the button even method I write: private void button1_Click(object sender,...
2
by: anonymous | last post by:
is there a way to surpress the insertion cursor in a rich text box? for instance, i might want a RichTextBox to display some text as a Label would-- readonly, no insertion cursor though text...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
1
by: papalarge | last post by:
Hey all... I've been using the following to calculate the height the textbox needs to be in order to grow it vertically to its necessary size. textbox1.Height =...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
1
by: Speebs | last post by:
Hello, I have a little form that people can fill out to generate CD labels from an RTF template. The template basically contains variables that are replaced by the text typed into the form. ...
3
Shinobi
by: Shinobi | last post by:
c#.net I have 2 forms. richtextbox1 is placed in form1. listbox1 is used in form2. selectedindex of listbox1 is passing path to form1. by using this path i am trying to load richtextbox1 using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.