Groups | Blog | Home
all groups > vb.net > may 2004 >

vb.net : Changing color with in a single label??


Bob Achgill
5/10/2004 11:52:58 PM
Label example: "See the dog run."

I would like to be able to highlight a given word in the
example label using another color than the rest of the
words in the sentence and/or maybe underline the
highlighted word.

Said another way...Does labels support in-line font/color
tags for setting text properties such as HTML does?

If not... then I guess I will need to dynamically
concatenate and display labels on the form for each word
using the desired font/color to build out the sentence.
If I want to do this sizing at run time then how can I
know how much width (pixels) to allocate for each label
such that I can place them neatly end to end?

Maybe I should be using a text box??
Bob Achgill
5/11/2004 7:32:43 AM
Rich Text Box did great!

Here is Hello World written to MyRichTextBox

rtbMyRichTextBox.SelectionFont = New Font("arial", 12,
FontStyle.Bold)

rtbMyRichTextBox.SelectionColor = Color.Red

rtbMyRichTextBox.SelectedText() = "Hello "

rtbMyRichTextBox.SelectionFont = New Font("arial", 10,
FontStyle.Bold)

rtbWordSentence.SelectionColor = Color.Black

rtbMyRichTextBox.SelectedText() = "World"



[quoted text, click to view]
Cor Ligthert
5/11/2004 9:04:55 AM
Hi Bob,

In my opinion you can use GDI, however when it was my problem I would first
look what the Rich Text Box could do for me. (I never have done this
problem)

Cor.


hirf-spam-me-here NO[at]SPAM gmx.at
5/11/2004 12:29:04 PM
* "Cor Ligthert" <notfirstname@planet.nl> scripsit:
[quoted text, click to view]

Full ACK. The RichTextBox is the way to go (locked + cursor set to an
arrow etc.).

--
Herfried K. Wagner [MVP]
Bob Achgill
5/11/2004 1:01:32 PM
I take it that "locked" means to set the Rich text Box
Property: Read only set to true

But what does "set to arrow mean"?

Just wondering.

Thanks!



[quoted text, click to view]
Cor Ligthert
5/11/2004 10:10:20 PM
Hi Bob,

The cursor is the mouspointer, that is normal the Arrow, so you can set that
to an arrow for that box
\\\\
Me.RichTextBox1.Cursor = Cursors.Arrow
////
Cor

hirf-spam-me-here NO[at]SPAM gmx.at
5/11/2004 10:28:51 PM
* "Cor Ligthert" <notfirstname@planet.nl> scripsit:
[quoted text, click to view]

ACK. In addition to that, we must prevent the user from selecting
text... I am not sure at the moment how to do that.

--
Herfried K. Wagner [MVP]
AddThis Social Bookmark Button