Specifying Different Colors for Different Characters within a Label.

  • Thread starter Thread starter fieryjack
  • Start date Start date
F

fieryjack

Hi All

I wish to create a label of a specific color (say blue) to display a
windows form, from a string of characters. However for an arbitrary
set of characters contained in the string (for example corresponding to
occurences of a certain character) i would like to use an alternate
color (say red).

Is there a straightforward way to obtain this degree of fine control in
adding color to a string?
I code in C++, manipulating characters in strings is not the
difficulty, i lack the understanding of the relevant functionality of
the classes available in .NET for windows forms. I suspect using a
"label" is not appropriate, but i do not know what the actual solution
to the problem would entail. I would be extremely grateful for any help
or references to a possible solution.

Many Thanks

Jonathan
 
fieryjack said:
I wish to create a label of a specific color (say blue) to display a
windows form, from a string of characters. However for an arbitrary
set of characters contained in the string (for example corresponding to
occurences of a certain character) i would like to use an alternate
color (say red).

You may want to use a richtextbox control instead of the label to display
rich-text:

\\\
With Me.RichTextBox1
.BorderStyle = BorderStyle.None
.BackColor = SystemColors.Control
.Enabled = False
.Text = "Bla Bla Bla Bla Bla Bla Bla Bla"
.SelectAll()
.SelectionColor = SystemColors.ControlText
.Select(10, 5)
.SelectionColor = Color.Red
End With
///
 
Back
Top