Changing color with in a single label??

B

Bob Achgill

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??
 
C

Cor Ligthert

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.
 
H

Herfried K. Wagner [MVP]

* "Cor Ligthert said:
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)

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

Bob Achgill

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"
 
B

Bob Achgill

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!
 
C

Cor Ligthert

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
 
H

Herfried K. Wagner [MVP]

* "Cor Ligthert said:
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
////

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

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

Top